コード例 #1
0
ファイル: WorldAgent.cs プロジェクト: emqk/Lands-of-Akslop
    protected void Update()
    {
        RefreshPath();

        if (currPath != null)
        {
            DrawPath(currPath.corners);
        }

        if (IsDestinationObjectReached())
        {
            if (destinationObject.GetWorldActorDockedInObject() == null)
            {
                Debug.Log("Object reached", destinationObject.gameObject);
                destinationObject.OnThisObjectReached(this);
            }

            //Move all my items to destination City even if City is docking other agent
            if (destinationObject.GetComponent <City>())
            {
                destinationObject.GetComponent <City>().OnThisObjectEntrancePosition(this);
            }

            Debug.Log("I am on my destination pos! : " + name, gameObject);
        }

        ControlAnimations();
    }
コード例 #2
0
ファイル: IdleState.cs プロジェクト: emqk/Lands-of-Akslop
    void GoToMyNearestCity(EnemyAgent owner)
    {
        TargetableObject building = null;
        TargetableObject dockedIn = owner.GetDockedIn();

        if (dockedIn)
        {
            if (dockedIn.GetComponent <City>())
            {
                building = dockedIn;
                dockedIn.GetArmy().MoveAllUnitsToOtherArmy(owner.GetArmy());
                // dockedIn.GetArmy().MoveUnitToOtherArmy(0, owner.GetArmy());
                //GoToMyPosition(owner);
            }
            else
            {
                building = owner.MyCountry.GetNearestUndockedCity(owner);
                owner.MoveToTargetObject(owner);
            }
        }
        else
        {
            building = owner.MyCountry.GetNearestUndockedCity(owner);
            if (building)
            {
                owner.MoveToTargetObject(building);
            }
            else
            {
                GoToMyPosition(owner);
            }
        }
    }
コード例 #3
0
        private void Interact(TargetableObject obj)
        {
            switch (obj.TargetableObjectType)
            {
            case TargetableObject.TargetableObjectTypes.Obtainable:
                try {
                    ObtainableObject obtObj = obj.GetComponent <ObtainableObject>();
                    _inventoryController.AddItem(obtObj.GetItem());
                    Destroy(obj.gameObject);
                }
                catch (InventoryController.InventoryFullException e) {
                    //Trigger object animation here
                }
                break;

            default:
                break;
            }
        }
コード例 #4
0
 public override void Initialize(TargetableObject targetableObject)
 {
     _engine       = targetableObject.GetComponent <Engine>();
     _initialSpeed = _engine.currentSpeed;
 }