コード例 #1
0
ファイル: Logic.cs プロジェクト: ComposerCookie/WanderingSoul
        public static void AttackSpawnable(LivingObject attacker, SpawnSpawnable _object)
        {
            if (_object is SpawnBuildable)
            {
                if (attacker is NPC)
                {
                    NPC n = (NPC)attacker;
                    Buildable r = (Buildable)Program.Data.GetBuildableList()[_object.ID];
                    //if (n.Equipment[11] != null && Program.Data.MyItems[n.Equipment[11].ID] is ToolItem)
                    //{
                        _object.CurHealth--;
                        if (_object.CurHealth == 0)
                        {
                            //for (int i = 0; i < r.Give.Count; i++)
                            //{
                            //    n.CurMap.Drop[_object.Y + n.CurMap.MinY][_object.X + n.CurMap.MinX].Add(r.Give[i]);
                            //}
                            n.CurMap.SpawnedSpawnable[n.CurMap.SpawnedSpawnableLocation[_object.Y + n.CurMap.MinY][_object.X + n.CurMap.MinX]] = null;
                            n.CurMap.NullList.Add(n.CurMap.SpawnedSpawnableLocation[_object.Y + n.CurMap.MinY][_object.X + n.CurMap.MinX]);
                            n.CurMap.SpawnedSpawnableLocation[_object.Y + n.CurMap.MinY][_object.X + n.CurMap.MinX] = -1;
                        }
                        Program.Log.AddMessage((int)InGameLogMessageType.Event, attacker.Name + " attacked " + Program.Data.GetBuildableList()[_object.ID].Name);
                    //}
                    //else
                    //    Program.Log.AddMessage((int)InGameLogMessageType.Notification, attacker.Name + " don't have the necessary tool to harvest this");
                }
            }

            else if (_object is SpawnResource)
            {
                if (attacker is NPC)
                {
                    NPC n = (NPC)attacker;
                    Resource r = (Resource)Program.Data.GetResourceList()[_object.ID];
                    if (((n.Equipment[11] != null && Program.Data.MyItems[n.Equipment[11].ID] is ToolItem) || (n.Equipment[7] != null && Program.Data.MyItems[n.Equipment[7].ID] is ToolItem)) && Logic.CurrentParty.MainParty.MyParty[0].KnowledgeKnown.Contains(1))
                    {
                        _object.CurHealth--;
                        if (_object.CurHealth == 0)
                        {
                            for (int i = 0; i < r.Give.Count; i++)
                            {
                                n.CurMap.Drop[_object.Y + n.CurMap.MinY][_object.X + n.CurMap.MinX].Add(new SpawnItems(r.Give[i].ID));
                            }
                            n.CurMap.SpawnedSpawnable[n.CurMap.SpawnedSpawnableLocation[_object.Y + n.CurMap.MinY][_object.X + n.CurMap.MinX]] = null;
                            n.CurMap.NullList.Add(n.CurMap.SpawnedSpawnableLocation[_object.Y + n.CurMap.MinY][_object.X + n.CurMap.MinX]);
                            n.CurMap.SpawnedSpawnableLocation[_object.Y + n.CurMap.MinY][_object.X + n.CurMap.MinX] = -1;
                        }
                        Program.Log.AddMessage((int)InGameLogMessageType.Event, attacker.Name + " tried to harvest " + Program.Data.GetResourceList()[_object.ID].Name);
                    }
                    else
                        Program.Log.AddMessage((int)InGameLogMessageType.Notification, attacker.Name + " don't have the necessary tool or knowledge to harvest this");
                }
            }
        }
        public static void AttackSpawnable(LivingObject attacker, SpawnSpawnable _object)
        {
            if (_object is SpawnBuildable)
            {
                if (attacker is NPC)
                {
                    NPC n = (NPC)attacker;
                    Buildable r = (Buildable)Program.Data.GetBuildableList()[_object.ID];
                    //if (n.Equipment[11] != null && Program.Data.MyItems[n.Equipment[11].ID] is ToolItem)
                    //{
                        _object.CurHealth--;
                        if (_object.CurHealth == 0)
                        {
                            //for (int i = 0; i < r.Give.Count; i++)
                            //{
                            //    Program.MyMap.Drop[_object.Y + Program.MyMap.MinY][_object.X + Program.MyMap.MinX].Add(r.Give[i]);
                            //}
                            Program.MyMap.SpawnedSpawnable[Program.MyMap.SpawnedSpawnableLocation[_object.Y + Program.MyMap.MinY][_object.X + Program.MyMap.MinX]] = null;
                            Program.MyMap.NullList.Add(Program.MyMap.SpawnedSpawnableLocation[_object.Y + Program.MyMap.MinY][_object.X + Program.MyMap.MinX]);
                            Program.MyMap.SpawnedSpawnableLocation[_object.Y + Program.MyMap.MinY][_object.X + Program.MyMap.MinX] = -1;
                        }
                        Program.Log.AddMessage((int)InGameLogMessageType.Event, attacker.Name + " attacked " + Program.Data.GetBuildableList()[_object.ID].Name);
                    //}
                    //else
                    //    Program.Log.AddMessage((int)InGameLogMessageType.Notification, attacker.Name + " don't have the necessary tool to harvest this");
                }
            }

            else if (_object is SpawnResource)
            {
                if (attacker is NPC)
                {
                    NPC n = (NPC)attacker;
                    Resource r = (Resource)Program.Data.GetResourceList()[_object.ID];
                    if (n.Equipment[11] != null && Program.Data.MyItems[n.Equipment[11].ID] is ToolItem)
                    {
                        _object.CurHealth--;
                        if (_object.CurHealth == 0)
                        {
                            for (int i = 0; i < r.Give.Count; i++)
                            {
                                Program.MyMap.Drop[_object.Y + Program.MyMap.MinY][_object.X + Program.MyMap.MinX].Add(r.Give[i]);
                            }
                            Program.MyMap.SpawnedSpawnable[Program.MyMap.SpawnedSpawnableLocation[_object.Y + Program.MyMap.MinY][_object.X + Program.MyMap.MinX]] = null;
                            Program.MyMap.NullList.Add(Program.MyMap.SpawnedSpawnableLocation[_object.Y + Program.MyMap.MinY][_object.X + Program.MyMap.MinX]);
                            Program.MyMap.SpawnedSpawnableLocation[_object.Y + Program.MyMap.MinY][_object.X + Program.MyMap.MinX] = -1;
                        }
                        Program.Log.AddMessage((int)InGameLogMessageType.Event, attacker.Name + " tried to harvest " + Program.Data.GetResourceList()[_object.ID].Name);
                    }
                    else
                        Program.Log.AddMessage((int)InGameLogMessageType.Notification, attacker.Name + " don't have the necessary tool to harvest this");
                }
            }
        }
コード例 #3
0
ファイル: Logic.cs プロジェクト: ComposerCookie/WanderingSoul
 public static int GetSpawnableType(SpawnSpawnable obj)
 {
     int type = -1;
     if (obj is SpawnResource)
         type = 0;
     else if (obj is SpawnBuildable)
     {
         if (obj is SpawnBuildableBuilding)
             type = 1;
     }
     return type;
 }