//Called once when this object initializes void Start() { plane = GetComponent <AeroPlane>(); turnCooldown = new Timers.CooldownTimer(3); planeBehaviour = GetComponent <PlaneBehaviour>(); enemy = GameHandler.Instance.Player; }
void defineVariables() { plane = GetComponent <AeroPlane>(); elevator = plane.getPart("elevator"); gear = plane.getPart("gear"); propeller = plane.getPart("propeller"); flap = plane.getPart("flap"); throttleTimer = new Timers.CooldownTimer(0.01f); shootingTimer = new Timers.CooldownTimer(0.08f); state = PlaneState.common; }
private LevelBlock GenLoadedLevelBlock (int index, Vector2 pos, float scrollSpeed, float startOffset, float tileSize) { LevelBlock block = Instantiate(levelBlockPrefab, new Vector3(pos.x, pos.y, 0f), Quaternion.identity) as LevelBlock; block.type = Scroller.ScrollType.Vertical; block.scrollSpeed = scrollSpeed; block.startOffset = startOffset; block.tileSize = tileSize; BlockData blockData = levelData.blocks[index]; block.bgTex = backgroundTex[blockData.bgIndex]; block.groundTex = blockData.ground ? groundTex : null; block.sideTex = sideTex[blockData.sideIndex]; foreach (var dogParam in blockData.dogs) { EnemyDog dog = Instantiate(enemyDogPrefab, new Vector3(pos.x + dogParam._posX, pos.y + dogParam._posY, 0f), Quaternion.identity) as EnemyDog; dog.wanderRange = dogParam._wanderRange; dog.wanderFreq = dogParam._wanderFreq; dog.wanderOffset = dogParam._wanderOffset; dog.fallingAcc = dogParam._fallingAcc; dog.maxFallingSpeed = dogParam._maxFallingSpeed; dog.transform.parent = block.transform; block.enemyDogs.Add(dog); } foreach (var planeParam in blockData.planeParams) { AeroPlane pl = Instantiate(planePrefab, new Vector3(pos.x + planeParam._posX, pos.y + planeParam._posY, 0f), Quaternion.identity) as AeroPlane; pl.transform.parent = block.transform; pl.direction = planeParam._direction; pl.flyDist = planeParam._flyDist; pl.flySpeed = planeParam._flySpeed; pl.waitTime = planeParam._waitTime; pl.transform.parent = block.transform; block.enemyPlanes.Add(pl); } foreach (var powerUpParam in blockData.powerUpParams) { PowerUp pu = Instantiate(powerUpPrefab, new Vector3(pos.x + powerUpParam._posX, pos.y + powerUpParam._posY, 0f), Quaternion.identity) as PowerUp; pu.transform.parent = block.transform; } foreach (var birdParam in blockData.birdParams) { Bird bird = Instantiate(birdPrefab, new Vector3(pos.x + birdParam._posX, pos.y + birdParam._posY, 0f), Quaternion.identity) as Bird; bird.transform.parent = block.transform; bird.direction = birdParam._direction; bird.flyDist = birdParam._flyDist; bird.flySpeed = birdParam._flySpeed; bird.waitTime = birdParam._waitTime; bird.transform.parent = block.transform; block.birds.Add(bird); } foreach (var ufoParam in blockData.ufoParams) { Ufo ufo = Instantiate(ufoPrefab, new Vector3(pos.x + ufoParam._posX, pos.y + ufoParam._posY, 0f), Quaternion.identity) as Ufo; ufo.transform.parent = block.transform; ufo.direction = ufoParam._direction; ufo.flyDist = ufoParam._flyDist; ufo.flySpeed = ufoParam._flySpeed; ufo.waitTime = ufoParam._waitTime; ufo.circularMoveRadius = ufoParam._circularMoveRadius; ufo.circularMoveFreq = ufoParam._circularMoveFreq; ufo.transform.parent = block.transform; block.ufos.Add(ufo); } foreach (var miscParam in blockData.miscParams) { var miscPrefab = miscPrefabs[miscParam._type]; GameObject misc = Instantiate(miscPrefab, new Vector3(pos.x + miscParam._posX, pos.y + miscParam._posY, 0f), Quaternion.identity) as GameObject; misc.transform.localScale = Vector3.one * miscParam._size; misc.transform.parent = block.transform; block.miscs.Add(misc); } block.PeriodOver += OnBlockEnd; return(block); }