Beispiel #1
0
    public static IDamageableComponent GetDamageableChecked(this IMyGameObject obj)
    {
        IDamageableComponent damageable = obj.GetDamageable();

        Contract.Assert(damageable != null, $"Using {nameof(GetDamageableChecked)} requires that damageable is included");
        return(damageable);
    }
        public void setDestination(Vector2 destination, Agent a)
        {
            if (a.destroyed)
            {
                return;
            }
            //Debug.Log("destination " + destination);
            IList <Vector2> l = PathFinderService.FindWay(new Vector2(a.x, a.y), destination, PlayerDataService.mySettings.pathFinderMethod, _matchDataService.myMatch.mapData, DataType.Matrix);

            if (l.Count > 0)
            {
                a.destinationWay = l;
                a.destination    = destination;
                a.startedWay();
                clearPoints();
                if (PlayerDataService.mySettings.showPoints)
                {
                    drawPoints();
                }
                if (a.currentGoal != Agent.Goal.Fight)
                {
                    a.currentGoal = Agent.Goal.None;
                    if (MatchDataS.myMatch.mapData.Table[(int)destination.x + 800][(int)destination.y + 800] != null)
                    {
                        IMyGameObject o = MatchDataS.myMatch.mapData.Table[(int)destination.x + 800][(int)destination.y + 800];
                        if (o.objectType == ObjectType.Food)
                        {
                            a.gold        = 0;
                            a.wood        = 0;
                            a.currentGoal = Agent.Goal.CollectFood;
                        }
                        if (o.objectType == ObjectType.Gold)
                        {
                            a.wood        = 0;
                            a.food        = 0;
                            a.currentGoal = Agent.Goal.CollectGold;
                        }
                        if (o.objectType == ObjectType.Wood)
                        {
                            a.gold        = 0;
                            a.food        = 0;
                            a.currentGoal = Agent.Goal.CollectWood;
                        }
                        else if (o.objectType == ObjectType.Building)
                        {
                            Building ob = (Building)o;
                            if ((int)ob.owner == _matchDataService.myMatch.mapData.currentPlayer)
                            {
                                a.currentGoal = Agent.Goal.Store;
                            }
                            else
                            {
                                a.currentGoal = Agent.Goal.Fight;
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
 public static bool IsDamageable(this IMyGameObject obj)
 {
     return(obj.GetDamageable() != null);
 }
 public void setDestination(Vector2 destination, IMyGameObject a)
 {
     setDestination(destination, (Agent)a);
 }