Esempio n. 1
0
    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);
    }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
 // 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;;
    }
Esempio n. 6
0
    // 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;
        }
    }
Esempio n. 7
0
    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);
                }
            }
        }
    }
Esempio n. 8
0
	public void Awake(){
		turret = GetComponent<TurretShoot>();
		spawner = GetComponent<SpawnMonks>();
		reticule = GetComponent<MoveReticule>();
	}
Esempio n. 9
0
 // Use this for initialization
 void Start()
 {
     tarShoot = GameObject.Find("turret/Cube").AddComponent<TurretShoot>();
     tarShoot.bullet_prefab = GameObject.Find("Sphere");
 }
Esempio n. 10
0
 void Start()
 {
     myShowEnemyStats = gameObject.GetComponent <ShowEnemyStats> ();
     myTurretShoot    = gameObject.GetComponent <TurretShoot> ();
 }