public PathOnPlatform(PathTD p, PathSection pSec, PathSection prev, PathSection next) { path=p; thisWP=pSec; prevNeighbouringWP=prev; nextNeighbouringWP=next; }
public PathOnPlatform(PathTD p, PathSection pSec, PathSection prev, PathSection next) { path = p; thisWP = pSec; prevNeighbouringWP = prev; nextNeighbouringWP = next; }
//[HideInInspector] public List<Vector3> wp=new List<Vector3>(); // Use this for initialization void Start() { indicatorT = (Transform)Instantiate(indicatorT, new Vector3(0, 9999999, 0), Quaternion.identity); indicator = indicatorT.gameObject.GetComponent <ParticleSystem>(); indicator.emissionRate = 0; path = gameObject.GetComponent <PathTD>(); StartCoroutine(EmitRoutine()); }
// Use this for initialization void Start() { indicatorT = (Transform)Instantiate(indicatorT); indicator = indicatorT.gameObject.GetComponent <ParticleSystem>(); indicator.emissionRate = 0; path = gameObject.GetComponent <PathTD>(); StartCoroutine(EmitRoutine()); }
// Use this for initialization void Start() { indicatorT=(Transform)Instantiate(indicatorT); indicator=indicatorT.gameObject.GetComponent<ParticleSystem>(); indicator.emissionRate=0; path=gameObject.GetComponent<PathTD>(); StartCoroutine(EmitRoutine()); }
//init a unitCreep, give it a path instance so it can retirve the path public void Init(PathTD p, int uID, int wID) { base.Init(); //reset waypoint SetWPCounter(0); currentPS = null; unitID = uID; waveID = wID; path = p; wpMode = false; if (flying) { thisT.position += new Vector3(0, flightHeightOffset, 0); } if (!stopMoving) { currentMoveSpd = moveSpeed * GlobalStatsModifier.CreepMoveSpd; } if (aniBody != null && animationMove != null && animationMove.Length > 0) { foreach (AnimationClip clip in animationMove) { aniBody.animation[clip.name].speed = Mathf.Max(moveSpeed * GlobalStatsModifier.CreepMoveSpd, currentMoveSpd) * moveAnimationModifier; } } //if using dynamic wap pos, set an offset based on gridsize if (path.dynamicWP > 0) { //float allowance=BuildManager.GetGridSize()*0.35f; float allowance = path.dynamicWP; dynamicOffset = new Vector3(Random.Range(-allowance, allowance), 0, Random.Range(-allowance, allowance)); thisT.position += dynamicOffset; } else { dynamicOffset = Vector3.zero; } if (spawnEffect != null) { ObjectPoolManager.Spawn(spawnEffect, thisT.position, Quaternion.identity); } PlaySpawn(); PlayMove(); lastPosition = thisT.position; }
void Awake() { path = (PathTD)target; if (path.waypoints == null) { path.waypoints = new Transform[2]; } EditorUtility.SetDirty(path); }
public PathTD FindPathTD(Transform currentPos, string pathName) { List <Transform> path = new List <Transform>(); lastPath = new List <Point>(); bool success = SearchPath(this.startNode); if (success) { PathNode node = this.destinationNode; GameObject platform = null; while (node.ParentNode != null) { platform = node.GameObject as GameObject; path.Add(platform.transform); lastPath.Add(new Point(node.Location.X, node.Location.Y)); node = node.ParentNode; } path.Add(currentPos); path.Reverse(); } // TODO better solution // PathTD works only in an parent GameObject --> hard to destroy afterwards GameObject go = new GameObject(pathName); //public GameObject PathIndicator1; //GameObject Indicator1; //Indicator1 = Instantiate(PathIndicator1, new Vector3(0,0,0), Quaternion.identity); //Instantiate(Indicator1, new Vector3(0, 0, 0), Quaternion.identity); go.AddComponent <PathTD>(); PathTD ret = go.GetComponent <PathTD>(); ret.dynamicOffset = 0.2f; ret.createPathLine = false; ret.wpList = path; ret.Init(); return(ret); }
void Start() { int rscCount = GameControl.GetResourceCount(); if (defaultPath == null) { defaultPath = (PathTD)FindObjectOfType(typeof(PathTD)); } if (autoGenWave) { InitAutoGenCreepPara(); if (spawnLimit == _SpawnLimit.Finite) { for (int i = 0; i < waves.Length; i++) { waves[i] = GenerateWave(i); } } } else { //prespawn the unit foreach (Wave wave in waves) { foreach (SubWave subWave in wave.subWaves) { if (subWave.unit != null) { UnitCreep unit = subWave.unit.GetComponent <UnitCreep>(); //make sure the creep value length match the resource count if (unit != null) { unit.InitValue(rscCount); } ObjectPoolManager.New(subWave.unit, subWave.count); } } } } //LoadCreep(); }
//init a unitCreep, give it a path instance so it can retirve the path public void Init(PathTD p, int uID, int wID) { base.Init(); //reset waypoint SetWPCounter(0); unitID = uID; waveID = wID; path = p; wpMode = false; if (flying) { thisT.position += new Vector3(0, flightHeightOffset, 0); } if (!stopMoving) { currentMoveSpd = moveSpeed; } if (aniBody != null && animationMove != null && animationMove.Length > 0) { foreach (AnimationClip clip in animationMove) { aniBody.animation[clip.name].speed = currentMoveSpd * moveAnimationModifier; } } if (spawnEffect != null) { ObjectPoolManager.Spawn(spawnEffect, thisT.position, Quaternion.identity); } PlaySpawn(); PlayMove(); }
//if this platform is part of a path, this function set the previous and next transform //public void SetNeighbouringWP(PathSection prev, PathSection next){ // prevNeighbouringWP=prev; // nextNeighbouringWP=next; //} public void SetPathObject(PathTD p, PathSection pSec, PathSection prev, PathSection next) { PathOnPlatform path=new PathOnPlatform(p, pSec, prev, next); pathObjects.Add(path); }
static void NewScene(bool flag) { EditorApplication.NewScene(); GameObject rootObj = new GameObject(); rootObj.name = "TDTK"; Transform rootT = rootObj.transform; GameObject obj = new GameObject(); obj.transform.parent = rootT; obj.name = "GameControl"; GameControl gameControl = obj.AddComponent <GameControl>(); ResourceManager rscManager = obj.GetComponent <ResourceManager>(); rscManager.InitResources(); foreach (Resource rsc in rscManager.resources) { rsc.value = 500; } obj = new GameObject(); obj.transform.parent = rootT; obj.name = "SpawnManager"; SpawnManager spawnManager = obj.AddComponent <SpawnManager>(); gameControl.spawnManager = spawnManager; gameControl.rangeIndicatorH = Resources.Load("RangeIndicatorH", typeof(Transform)) as Transform; gameControl.rangeIndicatorF = Resources.Load("RangeIndicatorF", typeof(Transform)) as Transform; gameControl.rangeIndicatorConeH = Resources.Load("RangeIndicatorConeH", typeof(Transform)) as Transform; obj = new GameObject(); obj.transform.parent = rootT; obj.name = "BuildManager"; BuildManager buildManager = obj.AddComponent <BuildManager>(); buildManager.InitTower(); Camera.main.transform.position = new Vector3(0, 12, -12); Camera.main.transform.rotation = Quaternion.Euler(45, 0, 0); obj = new GameObject(); obj.transform.parent = rootT; obj.name = "Path1"; PathTD path = obj.AddComponent <PathTD>(); if (flag) { path.waypoints = new Transform[3]; } else { path.waypoints = new Transform[2]; } obj = new GameObject(); obj.name = "waypoint1"; obj.transform.position = new Vector3(-12, 0, 0); obj.transform.parent = path.transform; path.waypoints[0] = obj.transform; obj = new GameObject(); obj.name = "waypoint2"; obj.transform.position = new Vector3(12, 0, 0); obj.transform.parent = path.transform; if (flag) { path.waypoints[2] = obj.transform; } else { path.waypoints[1] = obj.transform; } obj = GameObject.CreatePrimitive(PrimitiveType.Plane); obj.transform.parent = rootT; obj.name = "BuildPlatform"; if (flag) { obj.transform.localScale = new Vector3(1.8f, 1, 1.15f); obj.transform.position = Vector3.zero; obj.AddComponent <PlatformTD>(); } else { obj.transform.localScale = new Vector3(1.8f, 1, 0.3f); obj.transform.position = new Vector3(0, 0, -3); } obj.transform.renderer.material = Resources.Load("grid") as Material; buildManager.platforms = new Transform[1]; buildManager.platforms[0] = obj.transform; if (flag) { path.waypoints[1] = obj.transform; } if (flag) { obj = new GameObject(); obj.transform.parent = rootT; obj.name = "PathFinder"; obj.AddComponent <NodeGeneratorTD>(); obj.AddComponent <PathFinderTD>(); } spawnManager.defaultPath = path; //~ obj=new GameObject(); obj.transform.parent=rootT; //~ obj.name="UI"; //~ obj.AddComponent<UI>(); }
//init a unitCreep, give it a path instance so it can retirve the path public void Init(PathTD p, int uID, int wID) { base.Init(); //reset waypoint SetWPCounter(0); currentPS=null; unitID=uID; waveID=wID; path=p; wpMode=false; if(flying) thisT.position+=new Vector3(0, flightHeightOffset, 0); if(!stopMoving) currentMoveSpd=moveSpeed; if(aniBody!=null && animationMove!=null && animationMove.Length>0){ foreach(AnimationClip clip in animationMove){ aniBody.animation[clip.name].speed=currentMoveSpd*moveAnimationModifier; } } //if using dynamic wap pos, set an offset based on gridsize if(path.dynamicWP>0){ //float allowance=BuildManager.GetGridSize()*0.35f; float allowance=path.dynamicWP; dynamicOffset=new Vector3(Random.Range(-allowance, allowance), 0, Random.Range(-allowance, allowance)); thisT.position+=dynamicOffset; } else dynamicOffset=Vector3.zero; if(spawnEffect!=null) ObjectPoolManager.Spawn(spawnEffect, thisT.position, Quaternion.identity); PlaySpawn(); PlayMove(); }
public void SetPathObject(PathTD p, PathSection pSec, PathSection prev, PathSection next) { PathOnPlatform path = new PathOnPlatform(p, pSec, prev, next); pathObjects.Add(path); }
//init a unitCreep, give it a path instance so it can retirve the path public void Init(PathTD p, int uID, int wID) { base.Init(); //reset waypoint SetWPCounter(0); unitID=uID; waveID=wID; path=p; wpMode=false; if(flying) thisT.position+=new Vector3(0, flightHeightOffset, 0); if(!stopMoving) currentMoveSpd=moveSpeed; if(aniBody!=null && animationMove!=null && animationMove.Length>0){ foreach(AnimationClip clip in animationMove){ aniBody.animation[clip.name].speed=currentMoveSpd*moveAnimationModifier; } } if(spawnEffect!=null) ObjectPoolManager.Spawn(spawnEffect, thisT.position, Quaternion.identity); PlaySpawn(); PlayMove(); }