예제 #1
0
        private void Attack(Actor opponent)
        {
            GOmanager.playState.RaiseHappeningEvent(
                new HappeningArgs(
                    TypeOfComponent.TextMessage, "Attack registered  : "
                    + opponent.ToString()));

            foreach (Item item in Inventory)
            {
                // pr now : all available attacks are launched...
                WeaponComponent wc = (WeaponComponent)item.GetComponent(TypeOfComponent.WEAPON);
                if (wc != null && wc.wielded)
                {
                    foreach (Attack attack in wc.Attacks)
                    {
                        GOmanager.playState.RaiseHappeningEvent(
                            new HappeningArgs(
                                TypeOfComponent.TextMessage, attack.type));
                        // ==================================
                        // IMPACT IS CALCULATED FROM THE FORMULA
                        // p = mV   ( m - mass(Kg), V - velocity(m/s) )
                        // V = 66 m/s - (str - m(Kg) ) - rnd(15)
                        // 66 m/s max. velocity
                        // str - actor mass(Kg) / 10 ( avg for human : 7 )

                        float VelocityAtImpact = 66 - (Mass / 10 - wc.owner.Mass / 1000.0f);
                        float impact           = (wc.owner.Mass / 1000.0f) * VelocityAtImpact;
                        GOmanager.playState.RaiseHappeningEvent(
                            new HappeningArgs(
                                TypeOfComponent.TextMessage, "impact=" + impact.ToString() + " Kg m/s"));

                        opponent.RecieveDamage(impact);
                    }
                }
            }
        }
예제 #2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            Color c;

            renderer.display.ClearText();

            // switching between the different states of display
            switch (displayState)
            {
            case InventoryState.InventoryDisplay:
            {
                renderer.display.WriteLine("=== INVENTORY ===", Color.Yellow);
                for (int i = 0; i < actor.Inventory.Count; i++)
                {
                    if (i == index)
                    {
                        c = Color.Red;
                    }
                    else
                    {
                        c = Color.White;
                    }
                    renderer.display.WriteLine(actor.Inventory[i].ToString(), c);
                }
                break;
            }

            case InventoryState.ItemInteraction:
            {
                renderer.display.WriteLine("===   I T E M   ===", Color.Yellow);
                renderer.display.WriteLine(" ");
                renderer.display.WriteLine(selected.ToString().PadLeft(5));
                renderer.display.WriteLine("-----------------------");

                if (selected.GetComponent(TypeOfComponent.WEAPON) != null)
                {
                    WeaponComponent wc = (WeaponComponent)selected.GetComponent(TypeOfComponent.WEAPON);
                    renderer.display.WriteLine("Wielded : " + wc.wielded.ToString());
                }
                renderer.display.WriteLine("---------------------------");

                for (int i = 0; i < InteractionChoices.Count; i++)
                {
                    if (i == index)
                    {
                        c = Color.Red;
                    }
                    else
                    {
                        c = Color.White;
                    }
                    renderer.display.WriteLine(InteractionChoices[i].text, c);
                }
                break;
            }

            case InventoryState.ContainerEnterDisplay:
            {
                renderer.display.WriteLine("=== AVAILABLE CONTAINERS ===", Color.Yellow);
                renderer.display.WriteLine(" ");

                for (int i = 0; i < ContainerList.Count; i++)
                {
                    if (i == index)
                    {
                        c = Color.Red;
                    }
                    else
                    {
                        c = Color.White;
                    }
                    renderer.display.WriteLine(ContainerList[i].Name, c);
                }
                break;
            }

            case InventoryState.ContainerExitDisplay:
            {
                renderer.display.WriteLine("=== ITEMS IN CONTAINER ===", Color.Yellow);
                renderer.display.WriteLine(" ");
                ContainerComponent cc = (ContainerComponent)selectedContainer.GetComponent(TypeOfComponent.CONTAINER);
                for (int i = 0; i < cc.GetItems.Count; i++)
                {
                    if (i == index)
                    {
                        c = Color.Red;
                    }
                    else
                    {
                        c = Color.White;
                    }
                    renderer.display.WriteLine(cc.GetItems[i].Name, c);
                }
                break;
            }
            }
            renderer.Draw(spriteBatch);
        }
예제 #3
0
        private static List <ItemPrefab> CreateItems(Dictionary <int, string[]> dict)
        {
            List <ItemPrefab> itemPrefabs = new List <ItemPrefab>();

            for (int i = 0; i < dict.Count; i++)
            {
                ItemPrefab Prefab = new ItemPrefab();
                Prefab.Components = new List <Component>();
                foreach (string s in dict[i])
                {
                    string[] tokens = s.Split(':');
                    if (tokens[0].Trim() == "NAME")
                    {
                        Prefab.Name = tokens[1].Trim();
                    }
                    if (tokens[0].Trim() == "GLYPH")
                    {
                        Prefab.Glyph = Convert.ToInt32(tokens[1].Trim());
                    }
                    if (tokens[0].Trim() == "COLOR")
                    {
                        string[] values = tokens[1].Split(',');
                        Prefab.Color = new int[3] {
                            Convert.ToInt32(values[0].Trim()),
                            Convert.ToInt32(values[1].Trim()),
                            Convert.ToInt32(values[2].Trim())
                        };
                    }

                    if (tokens[0].Trim() == "MASS")
                    {
                        Prefab.Mass = Convert.ToInt32(tokens[1].Trim());
                    }

                    if (tokens[0].Trim() == "WEAPON")
                    {
                        WeaponComponent WC = new WeaponComponent(TypeOfComponent.WEAPON, null);
                        foreach (string weaponString in dict[i])
                        {
                            string[] weaponTokens = weaponString.Split(':');
                            if (weaponTokens[0].Trim() == "EDGE")
                            {
                                string[] weaponvalues = weaponTokens[1].Split(',');
                                WC.Attacks.Add(
                                    new Attack("EDGE",
                                               Convert.ToInt32(weaponvalues[0].Trim()),
                                               Convert.ToInt32(weaponvalues[1].Trim())
                                               )
                                    );
                            }
                        }
                        Prefab.Components.Add(WC);
                    }
                    if (tokens[0].Trim() == "CONTAINER")
                    {
                        ContainerComponent CC = new ContainerComponent(TypeOfComponent.CONTAINER, null);
                        foreach (string containerString in dict[i])
                        {
                            string[] containerTokens = containerString.Split(':');
                            if (containerTokens[0].Trim() == "CAPACITY")
                            {
                                CC.MaxCapacity = Convert.ToInt32(containerTokens[1]);
                            }
                        }

                        Prefab.Components.Add(CC);
                    }
                }
                itemPrefabs.Add(Prefab);
            }
            return(itemPrefabs);
        }