コード例 #1
0
    void stateMine()
    {
        if (cargo >= rCapacity)
        {
            _mineState = mineState.Seek;
        }

        if (target == null)
        {
            scanInstance now = targetScan(transform.position);
            if (now.hasTarget)
            {
                target = now.nearest;
                eventManager.RequestPosition(this.gameObject, target, (attackRange * (0.69f)), playerID);
            }
            else
            {
                if (cargo > 0)
                {
                    _mineState = mineState.Seek;
                }
                else
                {
                    _Logic_2 = _Logic_1;
                    _state   = State.Idle;
                    _Logic_1 = _state;
                }
            }
            return;
        }

        if (checkDistance() == false)
        {
            if (debugActive)
            {
                Debug.Log("Target Too Far");
            }

            _Logic_1 = _state;
            _state   = State.Move;
            return;
        }

        f_rate -= Time.deltaTime;

        if (f_rate <= 0)
        {
            eventManager.Damage(damage, this.gameObject, target);
            cargo += damage;
            f_rate = fireRate;
        }


        turn();
    }
コード例 #2
0
    void stateUnload()
    {
        if (target == null)
        {
            _mineState = mineState.Seek;
            return;
        }

        f_rate -= Time.deltaTime;

        if (!checkDistance())
        {
            _Logic_1 = _state;
            _state   = State.Move;
            return;
        }

        if (f_rate <= 0)
        {
            if (cargo <= 0)
            {
                if (navMem_1 != null)
                {
                    navTarget  = navMem_1.location;
                    _state     = State.Move;
                    _mineState = mineState.Mine;
                    navMem_1   = null;
                    return;
                }
                else
                {
                    _Logic_2 = _Logic_1;
                    _state   = State.Idle;
                    _Logic_1 = _state;
                }
            }

            cargo -= damage;
            eventManager.Collect(damage, playerID);
            f_rate = fireRate;
        }

        turn();
    }
コード例 #3
0
    void seekRefinery()
    {
        var fRef = findRefinery(transform.position);

        if (fRef != null)
        {
            target = fRef;
            eventManager.RequestPosition(this.gameObject, target, (attackRange * 0.69f), playerID);
            _mineState = mineState.Unload;
        }
        else
        {
            if (debugActive)
            {
                Debug.Log("No refineries");
            }

            _Logic_2 = _Logic_1;
            _state   = State.Idle;
            _Logic_1 = _state;
        }
    }
コード例 #4
0
    void onOrder(Order order, GameObject unit, int statusCode, int ID)
    {
        if (order.playerID == playerID)
        {
            if (unit == this.gameObject)
            {
                if (debugActive)
                {
                    Debug.Log("Order Recieved: " + name);
                }

                cMemory = order;

                if (order._type == Order.Type.Move || order._type == Order.Type.Recon)
                {
                    navTarget = order.navTarget;
                    _Logic_2  = _Logic_1;
                    _state    = State.Move;
                    _Logic_1  = _state;

                    _moveState = moveState.moveInit;
                    return;
                }

                if (order._type == Order.Type.Attack)
                {
                    if (_type == Type.mGun || _type == Type.missile)
                    {
                        if (order.unitTarget.tag == "Friendly")
                        {
                            if (order.unitTarget.GetComponent <unitAgent> ().playerID != playerID)
                            {
                                _Logic_2 = _Logic_1;
                                _state   = State.Attack;
                                _Logic_1 = _state;

                                navTarget = order.navTarget;
                                target    = order.unitTarget;

                                _moveState = moveState.moveInit;
                                return;
                            }
                        }

                        if (order.unitTarget.tag == "Structure")
                        {
                            if (order.unitTarget.GetComponent <buildLogic> ().playerID != playerID)
                            {
                                _Logic_2 = _Logic_1;
                                _state   = State.Attack;
                                _Logic_1 = _state;

                                navTarget = order.navTarget;
                                target    = order.unitTarget;

                                _moveState = moveState.moveInit;
                                return;
                            }
                        }

                        if (order.unitTarget.tag == "Resource")
                        {
                            if (isAggressive == true)
                            {
                                _Logic_2 = _Logic_1;
                                _state   = State.Attack;
                                _Logic_1 = _state;

                                navTarget = order.navTarget;
                                target    = order.unitTarget;

                                _moveState = moveState.moveInit;
                                return;
                            }
                            else
                            {
                                cMemory._type = Order.Type.Move;

                                _Logic_2 = _Logic_1;
                                _state   = State.Move;
                                _Logic_1 = _state;

                                navTarget = order.navTarget;
                                target    = null;

                                _moveState = moveState.moveInit;
                                return;
                            }
                        }
                    }

                    if (_type == Type.miner)
                    {
                        if (order.unitTarget.tag == "Resource")
                        {
                            _Logic_2 = _Logic_1;
                            _state   = State.Mine;
                            _Logic_1 = _state;

                            _mineState = mineState.Mine;

                            navTarget = order.navTarget;
                            target    = order.unitTarget;

                            _moveState = moveState.moveInit;
                            return;
                        }

                        if (order.unitTarget.tag == "Structure")
                        {
                            buildLogic bLogic = order.unitTarget.GetComponent <buildLogic> ();

                            if (bLogic.playerID == playerID && bLogic._type == buildLogic.Type.Refinery)
                            {
                                _Logic_2 = _Logic_1;
                                _state   = State.Mine;
                                _Logic_1 = _state;

                                _mineState = mineState.Unload;

                                navTarget = order.navTarget;
                                target    = order.unitTarget;

                                _moveState = moveState.moveInit;
                                return;
                            }
                        }
                    }

                    if (_type == Type.utility)
                    {
                        if (order.unitTarget.tag == "Friendly")
                        {
                            if (order.unitTarget.GetComponent <unitAgent> ().playerID == playerID)
                            {
                                _Logic_2 = _Logic_1;
                                _state   = State.Repair;
                                _Logic_1 = _state;

                                navTarget = order.navTarget;
                                target    = order.unitTarget;

                                _moveState = moveState.moveInit;
                                return;
                            }
                        }
                        if (order.unitTarget.tag == "betaStructure")
                        {
                            buildLogic bLogic = order.unitTarget.GetComponent <buildLogic> ();

                            if (bLogic.playerID == playerID)
                            {
                                _Logic_2 = _Logic_1;
                                _state   = State.Build;
                                _Logic_1 = _state;

                                navTarget = order.navTarget;
                                target    = order.unitTarget;

                                _moveState = moveState.moveInit;
                                return;
                            }
                        }
                    }
                }

                if (order._type == Order.Type.Patrol)
                {
                    patrolA = order.patrolA;
                    patrolB = order.patrolB;

                    _Logic_2 = _Logic_1;
                    _state   = State.Patrol;
                    _Logic_1 = _state;

                    _moveState = moveState.moveInit;
                    return;
                }
            }
        }
    }