Beispiel #1
0
    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();
    }
Beispiel #2
0
    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);
            }
        }
    }
Beispiel #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;
            }
        }
 public override void Initialize(TargetableObject targetableObject)
 {
     _engine       = targetableObject.GetComponent <Engine>();
     _initialSpeed = _engine.currentSpeed;
 }