예제 #1
0
    bool EquipInSlot(string slotName, FEntity entity)
    {
        // Debug.LogWarning("Warning: we aren't checking requirements");

        //no slot of that name
        if (!slots.ContainsKey(slotName))
        {
            return(false);
        }
        //slot already has something in it
        if (slots[slotName].slot != null)
        {
            return(false);
        }
        //already equipped elsewhere
        // Debug.Log(entity.GetComponent<NameComponent>()._name);
        if (entity.GetComponent <Equippable>().equipped)
        {
            return(false);
        }

        slots[slotName].slot = entity;

        return(true);
    }
예제 #2
0
 public void SelectInventoryItem(int item)
 {
     if (item < 1 || item > inventory.Count)
     {
         return;
     }
     else
     {
         //Get affordances
         FEvent        getaffs = inventory[item - 1].PropagateEvent(new FEvent(FEventCodes.GET_ENTITY_AFFORDANCES, "list", new List <string>()));
         List <string> affs    = getaffs.Get("list") as List <string>;
         string        suff    = "";
         for (int i = 0; i < affs.Count; i++)
         {
             if (i == 0)
             {
                 suff += " (";
             }
             suff += affs[i];
             if (i < affs.Count - 1)
             {
                 suff += ", ";
             }
             else
             {
                 suff += ")";
             }
         }
         selectedIndex = item;
         //Select the item
         ItemListWindow.instance.SelectItem(item - 1, suff);
         selectedInventoryItem = inventory[item - 1];
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            OleDbCommand comEski = new OleDbCommand("select Sifre from Entriy WHERE ((Entriy.Sifre)=@Geliyoo)", con);

            comEski.Parameters.AddWithValue("@Geliyoo", textBox1.Text);
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            try
            {
                OleDbDataReader rd = comEski.ExecuteReader();
                if (rd.Read())
                {
                    EEntity ent = new EEntity();
                    ent.KullaniciAdi = kullanici.Text;
                    ent.Sifre        = sifretxt.Text;
                    FEntity.Guncelle(ent);
                    kullanici.Text = string.Empty;
                    sifretxt.Text  = string.Empty;
                    textBox1.Text  = string.Empty;
                }
                else
                {
                    MessageBox.Show("Girdiğiniz Şifre Hatalı !!!", "Şifre Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally { con.Close(); }
        }
예제 #4
0
    public void SpawnPrototypeAt(string prototype, int x, int y)
    {
        FEntity proto = GambitPrototypes.instance.SpawnPrototype(prototype, x, y);

        spawnRequests.Add(proto);
        spawnLocationRequests.Add(new int[] { x, y });
    }
예제 #5
0
    public FEvent PropagateEventAOE(FEvent ev, FEntity entity, int range, float chance = 1f, bool exclude = true)
    {
        int[]  loc = GetGridLocation(entity);
        FEvent res = ev;

        for (int i = -range; i < range + 1; i++)
        {
            for (int j = -range; j < range + 1; j++)
            {
                if (Random.Range(0f, 1f) >= chance)
                {
                    continue;
                }
                if (i == 0 && j == 0)
                {
                    res = PropagateEventToTile(ev, entity, exclude);
                }
                else
                {
                    if (loc[0] + i >= 0 && loc[0] + i < width && loc[1] + j >= 0 && loc[1] + j < height)
                    {
                        PropagateEventToTile(ev, loc[0] + i, loc[1] + j);
                    }
                }
            }
        }
        return(res);
    }
예제 #6
0
 public override FEvent PropagateEvent(FEvent ev)
 {
     if (ev.eventName == FEventCodes.ENTITY_RECEIVE_MELEE_ATTACK)
     {
         FEntity attacker = ev.Get("attacker") as FEntity;
         attacker.PropagateEvent(new FEvent(FEventCodes.ENTITY_RECEIVE_MAGICAL_ATTACK, "damage", thornsAmount, "attacker", parentEntity, "element", Stat.ELEMENT.NONE));
     }
     return(ev);
 }
예제 #7
0
    public int StraightLineDistanceBetween(FEntity e1, FEntity e2)
    {
        // LocationComponent l1 = e1.GetComponent<LocationComponent>();
        // LocationComponent l2 = e2.GetComponent<LocationComponent>();
        FEvent loc1 = e1.PropagateEvent(new FEvent(FEventCodes.GET_LOCATION, "x", -1, "y", -1));
        FEvent loc2 = e2.PropagateEvent(new FEvent(FEventCodes.GET_LOCATION, "x", -1, "y", -1));

        return(Mathf.Max(Mathf.Abs(((int)loc1.Get("x") - ((int)loc2.Get("x")))), ((int)loc1.Get("y") - ((int)loc2.Get("y")))));
        // return (e1.gameObject.transform.position-e2.gameObject.transform.position).magnitude;
    }
예제 #8
0
    public override FEvent PropagateEvent(FEvent ev)
    {
        if (ev.eventName == FEventCodes.ENTITY_MELEE_ATTACK)
        {
            FEntity target = ev.Get("target") as FEntity;
            target.PropagateEvent(new FEvent(FEventCodes.INFLICT_BLEEDING));
        }

        return(ev);
    }
예제 #9
0
    public bool HasComponentAt(System.Type component, FEntity entity)
    {
        int[] loc = GetGridLocation(entity);
        bool  res = false;

        foreach (FEntity e in entityLocationMap[loc[0] + "," + loc[1]])
        {
            res = res || e.HasComponent(component);
        }
        return(res);
    }
예제 #10
0
    public void RemoveEntityAt(FEntity entity)
    {
        FEvent loc = entity.PropagateEvent(new FEvent(FEventCodes.GET_LOCATION, "x", -1, "y", -1));

        string key = ((int)loc.Get("x")) + "," + ((int)loc.Get("y"));

        if (!entityLocationMap.ContainsKey(key))
        {
            // Debug.Log("Could not find item");
            return;
        }
        entityLocationMap[key].Remove(entity);
    }
예제 #11
0
    public void AddRoom(int x, int y, int w, int h)
    {
        for (int i = x; i < x + w; i++)
        {
            FEntity wall = Instantiate(objectEntityPrefab);
            wall.Setup();
            wall.name = "Wall";
            wall.GetComponent <RenderComponent>().SetData("wall_bottom", new Color32(146, 126, 106, 255));
            wall.AddComponent("MovementBlockComponent");
            wall.AddComponent("BlockVisionComponent");
            entityList.Add(wall);
            map.PutEntityAt(wall, i, y);
            map.ClearFloorAt(i, y);
            wall.PropagateEvent(new FEvent(FEventCodes.ENTITY_SPAWN, "x", i, "y", y));

            wall = Instantiate(objectEntityPrefab);
            wall.Setup();
            wall.name = "Wall";
            wall.GetComponent <RenderComponent>().SetData("wall_bottom", new Color32(146, 126, 106, 255));
            wall.AddComponent("MovementBlockComponent");
            wall.AddComponent("BlockVisionComponent");
            entityList.Add(wall);
            map.PutEntityAt(wall, i, y + h - 1);
            map.ClearFloorAt(i, y + h - 1);
            wall.PropagateEvent(new FEvent(FEventCodes.ENTITY_SPAWN, "x", i, "y", y + h - 1));
        }
        for (int i = y; i < y + h; i++)
        {
            FEntity wall = Instantiate(objectEntityPrefab);
            wall.Setup();
            wall.name = "Wall";
            wall.GetComponent <RenderComponent>().SetData("wall_bottom", new Color32(146, 126, 106, 255));
            wall.AddComponent("MovementBlockComponent");
            wall.AddComponent("BlockVisionComponent");
            entityList.Add(wall);
            map.PutEntityAt(wall, x, i);
            map.ClearFloorAt(x, i);
            wall.PropagateEvent(new FEvent(FEventCodes.ENTITY_SPAWN, "x", x, "y", i));

            wall = Instantiate(objectEntityPrefab);
            wall.Setup();
            wall.name = "Wall";
            wall.GetComponent <RenderComponent>().SetData("wall_bottom", new Color32(146, 126, 106, 255));
            wall.AddComponent("MovementBlockComponent");
            wall.AddComponent("BlockVisionComponent");
            entityList.Add(wall);
            map.PutEntityAt(wall, x + w - 1, i);
            map.ClearFloorAt(x + w - 1, i);
            wall.PropagateEvent(new FEvent(FEventCodes.ENTITY_SPAWN, "x", x + w - 1, "y", i));
        }
    }
예제 #12
0
    public bool TryMoveEntity(FEntity ch, int tox, int toy)
    {
        FEvent moveIntoEvent = new FEvent(FEventCodes.ENTITY_TRY_MOVE_INTO);

        moveIntoEvent.Add("x", tox);
        moveIntoEvent.Add("y", toy);
        moveIntoEvent.Add("entity", ch);
        moveIntoEvent.Add("moveCancelled", false);

        FEvent loc1 = ch.PropagateEvent(new FEvent(FEventCodes.GET_LOCATION, "x", -1, "y", -1));
        int    dist = Mathf.Max(Mathf.Abs((int)loc1.Get("x") - tox), Mathf.Abs((int)loc1.Get("y") - toy));

        if (dist > 1)
        {
            Debug.Log(loc1.Get("x") + "," + loc1.Get("y"));
            List <MapTile> tiles = GameMap.instance.PathToFrom((int)loc1.Get("x"), (int)loc1.Get("y"), tox, toy);
            Debug.Log(tiles[0].x + "," + tiles[0].y);
            return(TryMoveEntity(ch, tiles[0].x, tiles[0].y));
        }

        List <FEntity> entitiesAtNewLocation = map.GetEntitiesAt(tox, toy);

        foreach (FEntity entity in entitiesAtNewLocation)
        {
            moveIntoEvent = entity.PropagateEvent(moveIntoEvent);
        }

        if ((bool)moveIntoEvent.Get("moveCancelled"))
        {
            //Nope
            if (moveIntoEvent.Get("moveBlockedByEntity") != null)
            {
                //End turn
                FEntity entity      = (FEntity)moveIntoEvent.Get("blockingEntity");
                FEvent  meleeAttack = ch.PropagateEvent(new FEvent(FEventCodes.ENTITY_MELEE_ATTACK, "target", entity, "damage", 0));
            }
            EndTurn();
            return(false);
        }

        FEvent moveEvent = new FEvent(FEventCodes.ENTITY_MOVE);

        moveEvent.Add("x", tox);
        moveEvent.Add("y", toy);

        moveEvent = ch.PropagateEvent(moveEvent);
        EndTurn();

        return(true);
    }
 /*
  * Potions were one of the last things I implemented before stopping on the example. This is a good example of a branch
  * point for detail in an ECS. A potion could be a container filled with a liquid, and the liquid has effects when it
  * touches things (the floor, a human, a zombie). However that felt too detailed/granular, so instead potions are things
  * that can be drunk or thrown, and then apply affects to the things they're drunk by or thrown at. So you can't find
  * a fountain of healing liquid or find someone who cries tears of healing (or maybe you could but it'd be another case
  * rather than reusing the same healing liquid in a new context).
  */
 public override FEvent PropagateEvent(FEvent ev)
 {
     if (ev.eventName == FEventCodes.DRINK)
     {
         //INGEST
         FEntity drinker = ev.Get("drinker") as FEntity;
         drinker.PropagateEvent(new FEvent(FEventCodes.HEAL_HP, "amount", 5));
     }
     else if (ev.eventName == FEventCodes.CONTAINER_BREAK)
     {
         //BROKE
         GameMap.instance.PropagateEventToTile(new FEvent(FEventCodes.HEAL_HP, "amount", 5), parentEntity, true);
     }
     return(ev);
 }
예제 #14
0
    // public void ProcessPendingAdditions(){
    //     foreach(string key in pendingAdditions.Keys){
    //         foreach(FEntity value in pendingAdditions[key]){
    //             if(entityLocationMap.ContainsKey(key)){
    //                 entityLocationMap[key].Add(value);
    //             }
    //             else{
    //                 List<FEntity> fes = new List<FEntity>();
    //                 fes.Add(value);
    //                 entityLocationMap.Add(key, fes);
    //             }
    //         }
    //     }
    //     pendingAdditions = new Dictionary<string, List<FEntity>>();
    // }

    public void PutEntityAt(FEntity entity, int x, int y)
    {
        string key = x + "," + y;

        // Debug.Log("Added "+entity.name+" to "+x+","+y);
        if (entityLocationMap.ContainsKey(key))
        {
            List <FEntity> fes = entityLocationMap[key];
            fes.Add(entity);
        }
        else
        {
            List <FEntity> fes = new List <FEntity>();
            fes.Add(entity);
            entityLocationMap.Add(key, fes);
        }
    }
예제 #15
0
    public bool CanSeePlayer(FEntity entity, int maxDistance)
    {
        Vector2 actualPosition       = GameMap.instance.GetMapLocation(entity);
        Vector2 actualPlayerPosition = GameMap.instance.GetMapLocation(playerEntity);
        Vector2 dist = actualPlayerPosition - actualPosition;

        if (dist.magnitude > maxDistance)
        {
            return(false);
        }
        if (Physics2D.Raycast(actualPosition, dist, dist.magnitude, 1 << 8).collider == null)
        {
            return(true);
        }

        return(false);
    }
예제 #16
0
    public override FEvent PropagateEvent(FEvent ev)
    {
        if (ev.eventName == FEventCodes.ENTITY_MELEE_ATTACK)
        {
            FEntity target = (FEntity)ev.Get("target");

            FEvent nameEvent = parentEntity.PropagateEvent(new FEvent(FEventCodes.GET_ENTITY_NAME, "name", "????"));
            string ourName   = (string)nameEvent.Get("fullstring");
            nameEvent = target.PropagateEvent(new FEvent(FEventCodes.GET_ENTITY_NAME, "name", "????"));
            string theirName = (string)nameEvent.Get("fullstring");

            MessageLog.instance.Log(ourName + " attacks the " + theirName + "!");


            target.PropagateEvent(new FEvent(FEventCodes.ENTITY_RECEIVE_MELEE_ATTACK, "attacker", this.parentEntity, "damage", (int)ev.Get("damage")));
        }
        return(ev);
    }
예제 #17
0
    public override FEvent PropagateEvent(FEvent ev)
    {
        if (dead && ev.eventName == FEventCodes.GET_NAME_MODIFIERS)
        {
            List <string> ss = (ev.Get("suffixes") as List <string>);
            ss.Add("(dead)");
            ev.Set("suffixes", ss);
        }

        if (dead)
        {
            return(ev);
        }

        if (ev.eventName == FEventCodes.ENTITY_TRY_MOVE_INTO)
        {
            FEntity mover = (FEntity)ev.Get("entity");

            //If the player tries to move into us, fight them
            if (mover.HasComponent(typeof(PlayerComponent)))
            {
                //Request attack
                ev.Set("moveBlockedByEntity", true);
                ev.Set("moveCancelled", true);
                ev.Set("blockingEntity", this.parentEntity);
                return(ev);
            }
            else
            {
                ev.Set("moveCancelled", true);
            }
        }
        else if (ev.eventName == FEventCodes.ENTITY_DIED)
        {
            //Change the avatar
            dead = true;
            parentEntity.PropagateEvent(new FEvent(FEventCodes.CHANGE_SPRITE, "spriteName", deathSpriteName));
            parentEntity.PropagateEvent(new FEvent(FEventCodes.CHANGE_SPRITE_LAYER, "spriteLayer", Model.instance.backgroundLayerName));
        }

        return(ev);
    }
예제 #18
0
    public FEvent PropagateEventToTile(FEvent ev, FEntity entity, bool exclude = true)
    {
        string key = GetPosition(entity);

        if (!entityLocationMap.ContainsKey(key))
        {
            Debug.LogError("Tried to send an event to an entity's location, but that location doesn't exist.");
            return(ev);
        }
        foreach (FEntity e in entityLocationMap[key])
        {
            if (e == entity && exclude)
            {
                continue;
            }

            e.PropagateEvent(ev);
        }
        return(ev);
    }
예제 #19
0
    public void UpdateVisionCone(FEntity visionEntity)
    {
        Vector3 actualPosition = GetMapLocation(visionEntity);

        Collider2D[] cs = Physics2D.OverlapCircleAll(actualPosition, 4, 1 << 9);
        foreach (Collider2D c in cs)
        {
            Vector2      meetingPoint = c.transform.position - actualPosition;
            RaycastHit2D tch          = Physics2D.Raycast(actualPosition, meetingPoint, meetingPoint.magnitude, 1 << 8);
            if (tch.collider == null)
            {
                c.gameObject.GetComponent <MapTile>().Show();
            }
            else
            {
                int[] loc = GetGridLocation(tch.collider.gameObject.GetComponent <FEntity>());
                maps[loc[0] + (loc[1] * width)].Show();
            }
        }
    }
예제 #20
0
    public override FEvent PropagateEvent(FEvent ev)
    {
        if (ev.eventName == FEventCodes.ENTITY_MELEE_ATTACK && Random.Range(0f, 1f) < mugChance)
        {
            FEntity        target        = (FEntity)ev.Get("target");
            List <FEntity> targetCarries = target.PropagateEvent(new FEvent(FEventCodes.GET_CARRIED_LIST, "list", new List <FEntity>())).Get("list") as List <FEntity>;
            if (targetCarries.Count > 0)
            {
                FEntity stolenItem = targetCarries[Random.Range(0, targetCarries.Count)];
                //Take the item
                target.PropagateEvent(new FEvent(FEventCodes.TRY_PICK_UP_OBJECT, "object", stolenItem));
                stolenItem.PropagateEvent(new FEvent(FEventCodes.PICKED_UP, "carrier", parentEntity));
                parentEntity.PropagateEvent(new FEvent(FEventCodes.RECEIVE_ITEM, "item", stolenItem));

                Debug.Log("Stolen item");
                // MessageLog.instance.Log("")
            }
        }
        return(ev);
    }
예제 #21
0
    public void EndTurn()
    {
        UpdateInterface();

        markedForRemoval = new List <FEntity>();
        FEntity entity = null;

        for (int i = 0; i < nonPlayerAgents.Count; i++)
        {
            entity = nonPlayerAgents[i];
            entity.PropagateEvent(new FEvent(FEventCodes.TAKE_TURN));
        }

        //Everyone's acted, now:
        for (int i = 0; i < nonPlayerAgents.Count; i++)
        {
            entity = nonPlayerAgents[i];
            entity.PropagateEvent(new FEvent(FEventCodes.END_TURN));
        }
        playerEntity.PropagateEvent(new FEvent(FEventCodes.END_TURN));

        for (int i = 0; i < markedForRemoval.Count; i++)
        {
            entity = markedForRemoval[i];
            if (entityList.Contains(entity))
            {
                entityList.Remove(entity);
            }
            if (nonPlayerAgents.Contains(entity))
            {
                nonPlayerAgents.Remove(entity);
            }
            Destroy(entity.gameObject);
        }
        ProcessSpawnRequests();
        ClearSpawnRequests();

        GameMap.instance.UpdateVisionCone(playerEntity);

        MessageLog.turn++;
    }
예제 #22
0
    internal List <FEntity> GetPickUppableItemsAt(FEntity entity, bool excludeSelf = true)
    {
        string key = GetPosition(entity);

        List <FEntity> res = new List <FEntity>();

        foreach (FEntity fe in entityLocationMap[key])
        {
            //We probably never want to pick stuff up off the thing we're looking at?
            if (excludeSelf && fe == entity)
            {
                continue;
            }

            FEvent takeables = fe.PropagateEvent(new FEvent(FEventCodes.GET_ALL_PICKABLES, "items", new List <FEntity>()));
            foreach (FEntity item in takeables.Get("items") as List <FEntity> )
            {
                res.Add(item);
            }
        }
        return(res);
    }
예제 #23
0
    public void DrinkSelected()
    {
        if (selectedInventoryItem == null || !selectedInventoryItem.HasComponent(typeof(Drinkable)))
        {
            return;
        }

        string _n = selectedInventoryItem.PropagateEvent(new FEvent(FEventCodes.GET_ENTITY_NAME)).Get("name") as string;

        MessageLog.instance.Log("You drink the " + _n + ".");

        FEvent drink = selectedInventoryItem.PropagateEvent(new FEvent(FEventCodes.DRINK, "drinker", playerEntity, "consumed", false));

        if ((bool)drink.Get("consumed"))
        {
            inventory.Remove(selectedInventoryItem);
            playerEntity.PropagateEvent(new FEvent(FEventCodes.CONSUME_ITEM, "item", selectedInventoryItem));
        }
        selectedInventoryItem = null;
        selectedIndex         = -1;

        ItemListWindow.instance.RefreshWindow(inventory);
    }
예제 #24
0
 public void RemoveFromWorld(FEntity entity)
 {
     map.RemoveEntityAt(entity);
 }
예제 #25
0
    public override FEvent PropagateEvent(FEvent ev)
    {
        if (ev.eventName == FEventCodes.TRY_PICK_UP_OBJECT)
        {
            FEntity entity = ev.Get("object") as FEntity;
            if (contents.Contains(entity))
            {
                contents.Remove(entity);
            }
        }
        if (ev.eventName == FEventCodes.LOSE_ITEM || ev.eventName == FEventCodes.CONSUME_ITEM || ev.eventName == FEventCodes.EQUIP_ITEM)
        {
            FEntity entity = ev.Get("item") as FEntity;
            if (contents.Contains(entity))
            {
                contents.Remove(entity);
            }
        }
        if (ev.eventName == FEventCodes.RECEIVE_ITEM || ev.eventName == FEventCodes.UNEQUIP_ITEM)
        {
            string name = (ev.Get("item") as FEntity).PropagateEvent(new FEvent(FEventCodes.GET_ENTITY_NAME)).Get("fullstring") as string;
            // Debug.Log("Added item to my inventory: "+name);
            FEntity entity = (FEntity)ev.Get("item");
            contents.Add(entity);
            return(ev);
        }
        else if (ev.eventName == FEventCodes.GET_VISIBLE_LIST || ev.eventName == FEventCodes.GET_ALL_PICKABLES)
        {
            //nothing to do here because we probably can't see our contents
            //q: is this a container's property? i'm not really sure.
            if (concealed)
            {
                return(ev);
            }
            else
            {
                foreach (FEntity ent in contents)
                {
                    ev = ent.PropagateEvent(ev);
                }
            }
        }
        else if (ev.eventName == FEventCodes.GET_CARRIED_LIST)
        {
            List <FEntity> list = ev.Get("list") as List <FEntity>;
            foreach (FEntity en in contents)
            {
                list.Add(en);
            }
            ev.Set("list", list);
        }
        else
        {
            foreach (FEntity fe in contents)
            {
                //Hmm.
            }
        }

        return(ev);
    }
예제 #26
0
    public string GetPosition(FEntity entity)
    {
        FEvent loc = entity.PropagateEvent(new FEvent(FEventCodes.GET_LOCATION, "x", -1, "y", -1));

        return(((int)loc.Get("x")) + "," + ((int)loc.Get("y")));
    }
예제 #27
0
    public override FEvent PropagateEvent(FEvent ev)
    {
        if (ev.eventName == FEventCodes.GET_NAME_MODIFIERS ||
            ev.eventName == FEventCodes.GET_LOCATION)
        {
            return(ev);
        }

        if (ev.eventName == FEventCodes.ENTITY_DIED)
        {
            foreach (EntitySlot slot in slots.Values)
            {
                if (slot.slot != null)
                {
                    parentEntity.PropagateEvent(new FEvent(FEventCodes.UNEQUIP_ITEM, "item", slot.slot));
                }
            }
        }

        if (ev.eventName == FEventCodes.DISARM_WEAPON)
        {
            List <FEntity> weapons = new List <FEntity>();
            //What can be disarmed?
            foreach (EntitySlot slot in slots.Values)
            {
                if (slot.slot != null && slot.slot.HasComponent(typeof(MeleeWeaponComponent)))
                {
                    weapons.Add(slot.slot);
                }
            }

            if (weapons.Count > 0)
            {
                FEntity disarmTarget = weapons[Random.Range(0, weapons.Count)];
                parentEntity.PropagateEvent(new FEvent(FEventCodes.UNEQUIP_ITEM, "item", disarmTarget));

                FEvent lev = parentEntity.PropagateEvent(new FEvent(FEventCodes.GET_LOCATION, "x", -1, "y", -1));
                parentEntity.PropagateEvent(new FEvent(FEventCodes.LOSE_ITEM, "item", disarmTarget, "x", (int)lev.Get("x"), "y", (int)lev.Get("y")));
                disarmTarget.PropagateEvent(new FEvent(FEventCodes.DROP_ITEM_HERE, "item", disarmTarget, "x", (int)lev.Get("x"), "y", (int)lev.Get("y")));

                FEvent name = disarmTarget.PropagateEvent(new FEvent(FEventCodes.GET_ENTITY_NAME));
                MessageLog.instance.Log(You("drop the " + name.Get("fullstring") as string));
            }

            return(ev);
        }

        if (ev.eventName == FEventCodes.ENTITY_SPAWN || ev.eventName == FEventCodes.GET_ENTITY_NAME)
        {
            //Ok so we clearly need better logic to determine what events propagate to children.
            return(ev);
        }

        foreach (EntitySlot slot in slots.Values)
        {
            if (slot.slot != null)
            {
                ev = slot.slot.PropagateEvent(ev);
            }
        }

        // if(ev.eventName == FEventCodes.TRY_PICK_UP_OBJECT){
        //     FEntity entity = ev.Get("object") as FEntity;
        //     foreach(EntitySlot slot in slots.Values){
        //         if(slot.slot != null && slot.slot == entity){
        //             slot.slot = null;
        //             entity.PropagateEvent(new FEvent(FEventCodes.WAS_UNEQUIPPED));
        //         }
        //     }
        // }

        if (ev.eventName == FEventCodes.EQUIP_ITEM)
        {
            string sn = ev.Get("slotName") as string;
            if (sn == null)
            {
                Debug.LogWarning("No slot provided for equip request");
                foreach (EntitySlot s in slots.Values)
                {
                    if (s.slot == null)
                    {
                        sn = s.slotName;
                    }
                }
            }
            if (sn == null)
            {
                return(ev);
            }

            FEntity en = ev.Get("item") as FEntity;
            if (EquipInSlot(sn, en))
            {
                en.PropagateEvent(new FEvent(FEventCodes.WAS_EQUIPPED));
            }
        }
        if (ev.eventName == FEventCodes.UNEQUIP_ITEM)
        {
            FEntity en = ev.Get("item") as FEntity;
            foreach (EntitySlot slot in slots.Values)
            {
                if (slot.slot != null && slot.slot == en)
                {
                    slot.slot = null;
                    en.PropagateEvent(new FEvent(FEventCodes.WAS_UNEQUIPPED));
                }
            }
        }
        //This is actually identical to unequipping it, but I duplicated it for clarity >_>
        if (ev.eventName == FEventCodes.LOSE_ITEM)
        {
            FEntity en = ev.Get("item") as FEntity;
            foreach (EntitySlot slot in slots.Values)
            {
                if (slot.slot != null && slot.slot == en)
                {
                    slot.slot = null;
                    en.PropagateEvent(new FEvent(FEventCodes.WAS_UNEQUIPPED));
                }
            }
        }

        if (ev.eventName == FEventCodes.GET_WIELDED_LIST)
        {
            List <FEntity> names = (List <FEntity>)ev.Get("list");
            foreach (EntitySlot slot in slots.Values)
            {
                if (slot.slot == null)
                {
                    continue;
                }
                names.Add(slot.slot);
            }
            ev.Set("list", names);
        }

        return(ev);
    }
예제 #28
0
 public int Manhattan(FEntity f1, FEntity f2)
 {
     int[] loc1 = GetGridLocation(f1);
     int[] loc2 = GetGridLocation(f2);
     return(Manhattan(loc1[0], loc1[1], loc2[0], loc2[1]));
 }
예제 #29
0
 public int GridDistance(FEntity f1, FEntity f2)
 {
     int[] loc1 = GetGridLocation(f1);
     int[] loc2 = GetGridLocation(f2);
     return(Mathf.Max(Mathf.Abs(loc1[0] - loc2[0]), Mathf.Abs(loc1[1] - loc2[1])));
 }
예제 #30
0
 public List <MapTile> PathToFrom(FEntity from, FEntity to)
 {
     int[] lf = GetGridLocation(from);
     int[] tf = GetGridLocation(to);
     return(PathToFrom(lf[0], lf[1], tf[0], tf[1]));
 }