3D tower guard game implements 2.2 management turret Creation Rules (Feekood language) and turret feekood
(Feekood language introduction and study)
Http://www.wooyoogame.com/doc/index (learning)
Http://www.wooyoogame.com (home)
Http://www.feekood.com/(Development page)
----------
In the previous chapter, the turret is created in two stages:
1. Create turret genie buttons and 3D models.
2. Manage turret building rules (no overlap, highground construction, creating turret on 3D maps ).
Next, we will introduce the second stage:
Based on the previous Folder level, we added 2 scripts, "TurretPanel. ais" to manage the turret and Main. ais Main portal.
First, comment out the last sentence in "TurretMesh. ais ".
The following is the code for "TurretPanel. ais:
Include ("TurretSpriteBtn. ais "); // introduce the genie button Include (" TurretMesh. ais "); // introduce the basic data of the turret model // Create a separate turret model for movement and comparison during creation Create (CreateTurretTab = {type:" mesh "; model: "TurretA1model"; texture: "TurretImg"; SimplerState: "wrap"; Shader: "phong"; Scale: {0.6, 0.6, 0.6}; show: false; Rotation: 180; scopeRadius: 2; ShowScope: true;}); // turret Management Panel TurretPanel = {CreateTab: false; // whether to create the flag CreateTab: -> {// event case (! Owner. createTab, {// restore the image of the turret genie button after creation $ ("TurretASpriteBtn "). texture = "TurretAImg" ;}) ;}; target: ""; // create the turret type TurretAssemble :{}; // The Name Of The created turret targetXYZ :{}; // create the space coordinate targetXYZ of the turret:-> // triggered when the coordinates change {case(size(owner.tar getXYZ)> 0, {// create the turret TurretName = create ({x: owner.tar getXYZ. x, y: owner.tar getXYZ. y, z: owner.tar getXYZ. z, Scale: {0.6, 0.6, 0.6}; model: owner.tar get + "1 model" ;}:: TurretBaseMesh); // put the created turret in the TurretAssemble variable owner. turretAssemble <TurretName ;}); // clear the coordinates of owner.tar getXYZ = {};};};
For this reason, the "3D map/MainMap. ais" script is supplemented with the following code: (The IsClick and IsMouseMove events are added)
Include ("MapBase. ais "); // introduce the basic map file include (".. /navcontrol/UiPanel. ais "); // application perspective File include (" 2 DMap/2Dmap. ais "); // introduce the 2D map create ({// master map name can be obtained through Getdata (" MainMap ") using name:" MainMap "; opposite: {}; opposite:-> {// the length and width of a 3D map are 32 grids, then the size of each grid is 4, so the total length and width are about 120. // the size of the four regions of the 3D map is 60*60 TargetX = 60 * (owner. opposite. x); // calculate the X TargetZ = 60 * (owner. opposite. z); // calculate the Z TargetY = MainCamera of the 3D space based on the proportion passed in. position-> 1; // obtain the Y of the 3D space of the current angle of view. // control the space coordinate MainCamera of the glasses that is moved to the target 3D angle of view within 500 milliseconds. position <: {TargetX, TargetY, TargetZ + 40}, 500}; // controls the spatial coordinate MainCamera of the object to be moved to the target 3D view within 500 milliseconds. target <:{ {TargetX, 0, TargetZ}, 500 };}; IsHitTest: true; // start the mouse and click IsClick: ==>// click 3D map ground {// determine whether the CreateTab attribute in the turret panel is true and the internal attribute Createtab case ($ ("TurretPanel "). createTab = true & owner. createtab, {// pass the creation completion information to the turret panel $ ("TurretPanel "). createTab = false; // pass the creation Space Point Information to the turret panel $ ("TurretPanel" pai.tar getXYZ = {x: owner. hitx, y: owner. hity, z: owner. hitz}; // set the internal attribute to false owner. createtab = false; // a separate turret hides the CreateTurretTab. show = false ;}) ;}; Createtab: true; // whether the turret can be marked with IsMouseMove: ==>{ // move the mouse event // determines whether the CreateTab attribute in the turret panel is true case ($ ("TurretPanel "). createTab = true, {owner. createtab = true; // initialize Createtab to true // assign a value to CreateTurretTab for a separate comparison turret attribute. texture = "TurretImg"; // turret texture CreateTurretTab. show = true; // the turret displays the CreateTurretTab. x = owner. hitx; // The X coordinate of the turret is changed to CreateTurretTab. y = owner. hity; // The Y coordinate of the turret is changed to CreateTurretTab. z = owner. hitz; // The zcoordinate of the turret is changed to the mouse point. // the turret cannot be built under the height (5). The case (CreateTurretTab. y <4.9, {CreateTurretTab. texture = "clear"; // remove the turret texture owner. createtab = false; // set the internal attribute Createtab to not be created}); // view whether the created turret overlaps with the created foreach (TurretPanel. turretAssemble, {// hit is the case (hit) (CreateTurretTab) function used to detect whether a collision occurs. name, value), {CreateTurretTab. texture = "clear"; // remove the turret texture owner. createtab = false; // set the internal attribute Createtab to not be created}); };:: MapA); // create a map;: Inheritance
Add a new Main script to control the entire game entry "Main. ais ".
The Code is as follows:
Include ("3D map/MainMap. ais"); // introduce the 3D map module Include ("Turret/TurretPanel. ais"); // introduce the Turret Module
This phase:
This stage source code link: http://pan.baidu.com/s/1qWDhUZq password: nnsl