Esempio n. 1
0
        public override void Update(GameTime time)
        {
            base.Update(time);

            if (Game.IsActive && Mouse.GetState().LeftButton == ButtonState.Pressed && prevMouse.LeftButton == ButtonState.Released ||
                Keyboard.GetState().IsKeyDown(Keys.Enter) && prevKeyboard.IsKeyUp(Keys.Enter))
            {
                var tiles = new List <Tile> {
                    Location
                };
                var aimingTile = Location.Neighbours.GetTile(MapDirection);
                if (aimingTile != null)
                {
                    tiles.Add(aimingTile);
                }

                var intersectingItems = new List <Tuple <IItem, Tile> >();

                Tuple <IItem, Tile> closest = null;
                float closestDistance       = float.MaxValue;

                foreach (var tile in tiles)
                {
                    foreach (var item in tile.SubItems)
                    {
                        float?res = Ray.Intersects(item.Bounding);
                        if (res != null)
                        {
                            intersectingItems.Add(new Tuple <IItem, Tile>(item, tile));
                            if (res.Value < closestDistance)
                            {
                                closest         = new Tuple <IItem, Tile>(item, tile);
                                closestDistance = res.Value;
                            }
                        }
                    }
                }

                if (closest != null)
                {
                    $"Click on Item: {closest.Item1}".Dump();
                    if (closest.Item1 is GrabableItem && Hand == null)
                    {
                        Hand = (GrabableItem)closest.Item1;
                        closest.Item1.Location = null;
                    }
                    else
                    {
                        Hand = closest.Item1.ExchangeItems(Hand);
                    }
                }
                else
                {
                    Fight();
                }
            }

            prevMouse    = Mouse.GetState();
            prevKeyboard = Keyboard.GetState();
        }
Esempio n. 2
0
        protected override bool TryInteract(ILeader theron, WallActuator actuator, bool isLast, out bool L0753_B_DoNotTriggerSensor)
        {
            L0753_B_DoNotTriggerSensor = false;//Doesnt matter
            if (theron.Hand == null)
            {
                if ((theron.Hand = Storage) == null)
                {
                    return(false);
                }

                Storage = null;
            }
            else
            {
                if ((theron.Hand?.FactoryBase != Data) || Storage != null)
                {
                    return(false);
                }

                Storage     = theron.Hand;
                theron.Hand = null;
            }

            TriggerLocalEffect(theron, actuator, true); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
            if ((Effect == SensorEffect.C03_EFFECT_HOLD) && theron.Hand != null)
            {
                L0753_B_DoNotTriggerSensor = true;
            }
            else
            {
                L0753_B_DoNotTriggerSensor = false;
            }
            return(true);
        }
Esempio n. 3
0
 public override IGrabableItem ExchangeItems(IGrabableItem item)
 {
     if (Hidden)
     {
         Hidden = false;
         UpdateTextures();
         return item;
     }
     else
     {
         if (item != null) //put it to alcove
         {
             storage.Add(item);
             $"Item {item} from hand put to aclove".Dump();
             return null;
         }
         else//take item from alcove
         {
             if (storage.Count > 0)
             {
                 var res = storage[0];
                 storage.RemoveAt(0);
                 $"Item {res} took from alcove to hand".Dump();
                 return res;
             }
             else
                 return null;
         }
     }
 }
Esempio n. 4
0
 public override IGrabableItem ExchangeItems(IGrabableItem item)
 {
     if (Hidden)
     {
         Hidden = false;
         UpdateTextures();
         return(item);
     }
     else
     {
         if (item != null) //put it to alcove
         {
             storage.Add(item);
             $"Item {item} from hand put to aclove".Dump();
             return(null);
         }
         else//take item from alcove
         {
             if (storage.Count > 0)
             {
                 var res = storage[0];
                 storage.RemoveAt(0);
                 $"Item {res} took from alcove to hand".Dump();
                 return(res);
             }
             else
             {
                 return(null);
             }
         }
     }
 }
Esempio n. 5
0
 public override IGrabableItem ExchangeItems(IGrabableItem item)
 {
     if(!Empty)
     {
         GameConsole.Instance?.RunCommand(new ChampionCommand { Actuator = this });
     }
     return base.ExchangeItems(item);
 }
        public override IGrabableItem ExchangeItems(IGrabableItem item)
        {
            Pressed ^= true;
            UpdateTextures();

            SendMessageAsync(Pressed);

            return base.ExchangeItems(item);
        }
        public override IGrabableItem ExchangeItems(IGrabableItem item)
        {
            Pressed ^= true;
            UpdateTextures();

            SendMessageAsync(activated: true);

            return(base.ExchangeItems(item));
        }
Esempio n. 8
0
        public void AddItem(IGrabableItem item, bool triggerEvent = true)
        {
            items.Add(item);

            if (triggerEvent)
            {
                ItemAdding?.Invoke(this, item);
            }
        }
Esempio n. 9
0
        public override IGrabableItem ExchangeItems(IGrabableItem item)
        {
            living ^= true;
            if (Living)
            {
                Live();
            }

            return(base.ExchangeItems(item));
        }
Esempio n. 10
0
        public IGrabableItem RemoveItem(IGrabableItem item, bool triggerEvent = true)
        {
            if (triggerEvent)
            {
                ItemRemoving?.Invoke(this, item);
            }

            items.Remove(item);
            return(item);
        }
Esempio n. 11
0
        public override IGrabableItem ExchangeItems(IGrabableItem item)
        {
            if (OnceOnly && !used)
                Switch();
            else if (!OnceOnly)
                Switch();

            used = true;
            return base.ExchangeItems(item);
        }
Esempio n. 12
0
 public override IGrabableItem ExchangeItems(IGrabableItem item)
 {
     if (!Empty)
     {
         GameConsole.Instance?.RunCommand(new ChampionCommand {
             Actuator = this
         });
     }
     return(base.ExchangeItems(item));
 }
Esempio n. 13
0
        public IGrabableItem TakeFromHand()
        {
            if (Hand == null)
            {
                throw new InvalidOperationException("Hand is empty.");
            }
            var res = Hand;

            Hand = null;
            return(res);
        }
Esempio n. 14
0
 public virtual bool AddItemTo(IGrabableItem item, int index)
 {
     if (index >= 0 && index < storage.Length && storage[index] == null && item.Factory.CanBeStoredIn(Type))
     {
         storage[index] = item;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 15
0
        int F305_xxxx_CHAMPION_GetThrowingStaminaCost(IGrabableItem item)
        {
            int L0923_i_Weight;

            int L0924_i_StaminaCost = MathHelper.Clamp(L0923_i_Weight = item.FactoryBase.Weight >> 1, 1, 10);//TODO sum weight of container

            while ((L0923_i_Weight -= 10) > 0)
            {
                L0924_i_StaminaCost += L0923_i_Weight >> 1;
            }
            return(L0924_i_StaminaCost);
        }
Esempio n. 16
0
 public virtual bool AddItemTo(IGrabableItem item, int index)
 {
     if (index >= 0 && index < storage.Length && storage[index] == null && item.Factory.CanBeStoredIn(Type))
     {
         storage[index] = item;
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 17
0
        public FloorItemStorage GetSpace(IGrabableItem grabable)
        {
            var space = grabable?.Location?.Space;

            if (space != null)
            {
                return(Storages.FirstOrDefault(s => s.Space.Area.Intersects(space.Area)) ?? Storages.First());
            }
            else
            {
                return(Storages.First());
            }
        }
Esempio n. 18
0
 public virtual bool AddItem(IGrabableItem item)
 {
     int freeIndex = Array.FindIndex(storage, i => i == null);
     if (freeIndex != -1 && item.Factory.CanBeStoredIn(Type))
     {
         storage[freeIndex] = item;
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 19
0
        public override IGrabableItem ExchangeItems(IGrabableItem item)
        {
            if (OnceOnly && !used)
            {
                Switch();
            }
            else if (!OnceOnly)
            {
                Switch();
            }

            used = true;
            return(base.ExchangeItems(item));
        }
Esempio n. 20
0
 public override IGrabableItem ExchangeItems(IGrabableItem item)
 {
     if (Activated && Constrain.IsAcceptable(item))
     {
         //TODO how to disable eating stuffs when job is done ???
         //Active = false;
         SendMessageAsync(activated: true);
         return(DestroyItem ? null : item);
     }
     else
     {
         return(item);
     }
 }
Esempio n. 21
0
        public virtual bool AddItem(IGrabableItem item)
        {
            int freeIndex = Array.FindIndex(storage, i => i == null);

            if (freeIndex != -1 && item.Factory.CanBeStoredIn(Type))
            {
                storage[freeIndex] = item;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 22
0
 public override IGrabableItem ExchangeItems(IGrabableItem item)
 {
     if (Activated && Constrain.IsAcceptable(item))
     {
         //TODO how to disable eating stuffs when job is done ???
         //Active = false;
         SendMessageAsync(activated: true);
         return DestroyItem ? null : item;
     }
     else
     {
         return item;
     }
 }
Esempio n. 23
0
        void F212_mzzz_PROJECTILE_Create(IGrabableItem P433_T_Thing, MapDirection P437_i_Direction, int P438_uc_KineticEnergy, int P439_uc_Attack, int P440_uc_StepEnergy)
        {
            Projectile L0467_ps_Projectile;
            Weapon     weapon = P433_T_Thing as Weapon;

            if (weapon == null)
            {
                L0467_ps_Projectile = new ImpactProjectile(P438_uc_KineticEnergy, P440_uc_StepEnergy, P439_uc_Attack, new ThrowImpact <IGrabableItem>(P433_T_Thing));
            }
            else
            {
                L0467_ps_Projectile = new ImpactProjectile(P438_uc_KineticEnergy, P440_uc_StepEnergy, P439_uc_Attack, new WeaponImpact(weapon));
            }
            L0467_ps_Projectile.Renderer = Factory.Renderers.GetProjectileSpellRenderer(L0467_ps_Projectile, P433_T_Thing.FactoryBase.Renderer.Texture);
            L0467_ps_Projectile.Run(attackProvider.Location, P437_i_Direction);
        }
Esempio n. 24
0
 public override IGrabableItem ExchangeItems(IGrabableItem item)
 {
     if (item == null)
     {
         var storedItem = items.LastOrDefault();
         if (storedItem != null)
         {
             items.RemoveAt(items.Count - 1);
             ObjectLeft();
         }
         return storedItem;
     }
     else
     {
         items.Add(item);
         ObjectEntered();
         return null;
     }
 }
Esempio n. 25
0
 public override IGrabableItem ExchangeItems(IGrabableItem item)
 {
     if (item == null)
     {
         var storedItem = items.LastOrDefault();
         if (storedItem != null)
         {
             items.RemoveAt(items.Count - 1);
             ObjectLeft();
         }
         return(storedItem);
     }
     else
     {
         items.Add(item);
         ObjectEntered();
         return(null);
     }
 }
Esempio n. 26
0
        protected override bool TryInteract(ILeader theron, WallActuator actuator, bool isLast, out bool L0753_B_DoNotTriggerSensor)
        {
            L0753_B_DoNotTriggerSensor = false; //Doesnt matter
            if (!isLast)
            {                                   /* If the sensor is not the last one of its type on the cell */
                return(false);
            }
            //F162_afzz_DUNGEON_GetSquareFirstObject(); //TODO is it possible to put item from one side of the wall and take it from antoher ?
            if ((theron.Hand?.FactoryBase != Data) || (Storage == null))
            {
                return(false);
            }

            var handItem = theron.Hand;

            theron.Hand = Storage;
            Storage     = handItem;
            L0753_B_DoNotTriggerSensor = false;
            return(true);
        }
Esempio n. 27
0
        public override IGrabableItem ExchangeItems(IGrabableItem item)
        {
            if (OnceOnly && used)
                return item;

            if (item == null || Constrain.IsAcceptable(item))
            {
                var res = Storage;
                Storage = item;

                UpdateDecoration();

                used = true;

                return res;
            }
            else
            {
                return item;
            }
        }
Esempio n. 28
0
        public bool ThrowOutItem(uint distance = 0)
        {
            if (Hand != null)
            {
                var targetLocation = CheckRoute(distance);

                if (targetLocation != null)
                {
                    Hand.Location = targetLocation;
                    Hand          = null;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        public override IGrabableItem ExchangeItems(IGrabableItem item)
        {
            if (OnceOnly && used)
            {
                return(item);
            }

            if (item == null || Constrain.IsAcceptable(item))
            {
                var res = Storage;
                Storage = item;

                UpdateDecoration();

                used = true;

                return(res);
            }
            else
            {
                return(item);
            }
        }
Esempio n. 30
0
 public void PutToHand(IGrabableItem item)
 {
     Hand = item;
 }
Esempio n. 31
0
 public IGrabableItem TakeFromHand()
 {
     if (Hand == null)
         throw new InvalidOperationException("Hand is empty.");
     var res = Hand;
     Hand = null;
     return res;
 }
Esempio n. 32
0
 public virtual IGrabableItem ExchangeItems(IGrabableItem item)
 {
     return item;
 }
Esempio n. 33
0
 public bool AddItem(IGrabableItem item) => inventoryImplementation.AddItem(item);
Esempio n. 34
0
 public virtual IGrabableItem ExchangeItems(IGrabableItem item)
 {
     return(item);
 }
Esempio n. 35
0
 public bool AddItem(IGrabableItem item) => bodyPartImplementation.AddItem(item);
Esempio n. 36
0
 public IGrabableItem ExchangeItems(IGrabableItem item) => item;
Esempio n. 37
0
 public override IGrabableItem ExchangeItems(IGrabableItem item)
 {
     SendMessageAsync(activated:true); 
     return base.ExchangeItems(item);
 }
Esempio n. 38
0
 public ExchangerActuator(Vector3 position, IGrabableItem storage, IConstrain exchangeConstrain, bool onceOnly) 
 {
     Constrain = exchangeConstrain;
     Storage = storage;
     OnceOnly = onceOnly;
 }
Esempio n. 39
0
 public bool AddItem(IGrabableItem item) => bodyPartImplementation.AddItem(item);
Esempio n. 40
0
        public bool ThrowOutItem(uint distance = 0)
        {
            if (Hand != null)
            {
                var targetLocation = CheckRoute(distance);

                if (targetLocation != null)
                {
                    Hand.Location = targetLocation;
                    Hand = null;
                    return true;
                }
                else
                    return false;
            }
            else
                return false;
        }
 public ExchangerActuator(Vector3 position, IGrabableItem storage, IConstrain exchangeConstrain, bool onceOnly)
 {
     Constrain = exchangeConstrain;
     Storage   = storage;
     OnceOnly  = onceOnly;
 }
Esempio n. 42
0
 public void PutToHand(IGrabableItem item)
 {
     Hand = item;
 }
Esempio n. 43
0
 public bool AddItemTo(IGrabableItem item, int index) => bodyPartImplementation.AddItemTo(item, index);
Esempio n. 44
0
 public bool AddItemTo(IGrabableItem item, int index) => inventoryImplementation.AddItemTo(item, index);
Esempio n. 45
0
 public IGrabableItem ExchangeItems(IGrabableItem item) => item;
Esempio n. 46
0
        public override IGrabableItem ExchangeItems(IGrabableItem item)
        {
            living ^= true;
            if (Living)
                Live();

            return base.ExchangeItems(item);
        }
Esempio n. 47
0
 public bool AddItemTo(IGrabableItem item, int index) => inventoryImplementation.AddItemTo(item, index);
Esempio n. 48
0
        public override void Update(GameTime time)
        {
            base.Update(time);

            if (Game.IsActive && Mouse.GetState().LeftButton == ButtonState.Pressed && prevMouse.LeftButton == ButtonState.Released
                || Keyboard.GetState().IsKeyDown(Keys.Enter) && prevKeyboard.IsKeyUp(Keys.Enter))
            {
                var tiles = new List<Tile> { Location };
                var aimingTile = Location.Neighbours.GetTile(MapDirection);
                if (aimingTile != null)
                    tiles.Add(aimingTile);

                var intersectingItems = new List<Tuple<IItem, Tile>>();

                Tuple<IItem, Tile> closest = null;
                float closestDistance = float.MaxValue;

                foreach (var tile in tiles)
                    foreach (var item in tile.SubItems)
                    {
                        float? res = Ray.Intersects(item.Bounding);
                        if (res != null)
                        {
                            intersectingItems.Add(new Tuple<IItem, Tile>(item, tile));
                            if (res.Value < closestDistance)
                            {
                                closest = new Tuple<IItem, Tile>(item, tile);
                                closestDistance = res.Value;
                            }
                        }
                    }

                if (closest != null)
                {
                    $"Click on Item: {closest.Item1}".Dump();
                    if (closest.Item1 is GrabableItem && Hand == null)
                    {
                        Hand = (GrabableItem)closest.Item1;
                        closest.Item1.Location = null;
                    }
                    else
                    {
                        Hand = closest.Item1.ExchangeItems(Hand);
                    }
                }
                else
                {
                    Fight();
                }
            }

            prevMouse = Mouse.GetState();
            prevKeyboard = Keyboard.GetState();
        }
Esempio n. 49
0
 public override IGrabableItem ExchangeItems(IGrabableItem item)
 {
     SendMessageAsync(activated: true);
     return(base.ExchangeItems(item));
 }
Esempio n. 50
0
 public bool AddItem(IGrabableItem item) => inventoryImplementation.AddItem(item);
Esempio n. 51
0
 public Sensor13(StorageSensorInitializer <IActuatorX> initializer) : base(initializer)
 {
     Storage = initializer.StoredItem;
 }
Esempio n. 52
0
 public bool AddItemTo(IGrabableItem item, int index) => bodyPartImplementation.AddItemTo(item, index);