public bool CanBuyTurret(TurretShoot.TurretType type, ref int price) { bool ret = false; switch (type) { case TurretShoot.TurretType.BLUE: if (blue_turret != null) { TurretShoot ts = blue_turret.GetComponent <TurretShoot>(); if (ts != null) { price = ts.GetPrice(); if (CanBuy(price)) { ret = true; } } } break; case TurretShoot.TurretType.RED: if (red_turret != null) { TurretShoot ts = red_turret.GetComponent <TurretShoot>(); if (ts != null) { price = ts.GetPrice(); if (CanBuy(price)) { ret = true; } } } break; case TurretShoot.TurretType.GREEN: if (green_turret != null) { TurretShoot ts = green_turret.GetComponent <TurretShoot>(); if (ts != null) { price = ts.GetPrice(); if (CanBuy(price)) { ret = true; } } } break; } return(ret); }
private void Awake() { this.Spawner = null; this._renderer = this.GetComponent <SpriteRenderer>(); this._turretShoot = this.GetComponent <TurretShoot>(); this.TurretBuilder = this.GetComponent <TurretBuilder>(); this._validDistance = false; this._building = false; }
public void Shoot() { // Недостаточное количество воды в запасе if (waterCapacity == minWaterCapacity) { InsufficientlyWaterError?.Invoke(this, new InsufficientlyWaterErrorEventArgs()); return; } // Пушка не подготовлена if (!weaponReady) { WeaponUnchargedError?.Invoke(this, new WeaponUnchargeErrorEventArgs()); return; } // Присваиваем null для случая, когда выстрел не попал ни в какое дерево (или дом) IFlammable objectToExtinguish = null; // Если пушка опущена, то можно потушить только ближайшее дерево (или дом) if (!up) { foreach (Vector2f coords in GetTargetPositions()) { objectToExtinguish = _terrain.GetFlammableObjects().Find(flammable => ((Entity)flammable).Position == coords); // Если нашли ближайшее дерево (или дом), то остальные не проверяем if (objectToExtinguish != null) { objectToExtinguish.Water(); break; } } } // Если пушка поднята, то можно потушить только одно дальнее дерево (или дом) else { objectToExtinguish = _terrain.GetFlammableObjects().Find(flammable => ((Entity)flammable).Position == GetTargetPositions()[0]); objectToExtinguish?.Water(); } TurretShoot?.Invoke(this, new ShootTurretEventArgs(objectToExtinguish)); // После выстрела сбрасываем давление, уменьшаем запасы воды, убираем заряд пушки waterPressure = minWaterPressure; waterCapacity--; weaponReady = false; }
// Use this for initialization void Start() { controller = GetComponent <CharacterController>(); enemyDetails = GetComponentInChildren <PlayerDetails>(); fm = GetComponent <FlockMember>(); hp = startHp; hit = false; StartCoroutine(UpdatePath()); explode = GetComponent <Explosion>(); bt = GetComponent <BehaviorTree>(); root = bt.root; ts = GetComponent <TurretShoot>(); BuildTree(); }
private void Awake() { var targetSelection = new TurretTargetSelector(this, range); var turretShoot = new TurretShoot(this, shotFrequency); var beingCarried = new BeingCarried(this); stateMachine = new StateMachine(); stateMachine.AddTransition(targetSelection, turretShoot, HasTarget()); stateMachine.AddAnyTransition(targetSelection, IsReadyForTarget()); stateMachine.AddAnyTransition(beingCarried, IsBeingCarried()); stateMachine.SetState(targetSelection); Func <bool> HasTarget() => () => Target != null && Target.gameObject.activeInHierarchy; Func <bool> IsReadyForTarget() => () => (Target == null || !Target.gameObject.activeInHierarchy) && carryingObject == null;; Func <bool> IsBeingCarried() => () => carryingObject != null;; }
// Use this for initialization void Start() { controller = GetComponent <CharacterController>(); enemyDetails = GetComponentInChildren <PlayerDetails>(); fm = GetComponent <FlockMember>(); hp = startHp; hit = false; StartCoroutine(UpdatePath()); explode = GetComponent <Explosion>(); isRanger = false; TurretShoot rangerTest = GetComponentInChildren <TurretShoot>(); if (rangerTest != null) { isRanger = true; } }
public void SpawnTurret(Vector3 pos, TurretShoot.TurretType type) { if (world_parent != null) { GameObject curr_en = null; switch (type) { case TurretShoot.TurretType.BLUE: if (blue_turret != null) { curr_en = Instantiate(blue_turret, pos, world_parent.transform.rotation); } break; case TurretShoot.TurretType.RED: if (red_turret != null) { curr_en = Instantiate(red_turret, pos, world_parent.transform.rotation); } break; case TurretShoot.TurretType.GREEN: if (green_turret != null) { curr_en = Instantiate(green_turret, pos, world_parent.transform.rotation); } break; } if (curr_en != null) { curr_en.transform.parent = world_parent.transform; TurretShoot turr_shoot = curr_en.GetComponent <TurretShoot>(); if (turr_shoot != null) { turr_shoot.SetManagers(this, event_system); } } } }
public void Awake(){ turret = GetComponent<TurretShoot>(); spawner = GetComponent<SpawnMonks>(); reticule = GetComponent<MoveReticule>(); }
// Use this for initialization void Start() { tarShoot = GameObject.Find("turret/Cube").AddComponent<TurretShoot>(); tarShoot.bullet_prefab = GameObject.Find("Sphere"); }
void Start() { myShowEnemyStats = gameObject.GetComponent <ShowEnemyStats> (); myTurretShoot = gameObject.GetComponent <TurretShoot> (); }