public BasicAttackAction(LivingObject caster, Attack id, int dir, AttackManager am)
 {
     Caster = caster;
     ID = id;
     Dir = dir;
     AM = am;
     switch (Dir)
     {
         case 0:
             X = Caster.X - 1;
             Y = Caster.Y;
             break;
         case 1:
             X = Caster.X;
             Y = Caster.Y - 1;
             break;
         case 2:
             X = Caster.X + 1;
             Y = Caster.Y;
             break;
         case 3:
             X = Caster.X;
             Y = Caster.Y + 1;
             break;
     }
     Animation = new SpawnAttackAnimation(ID.Animation, X, Y, Dir, false, this);
     Attacked = false;
 }
        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");
                }
            }
        }
Esempio n. 3
0
        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 AttackLivingObject(LivingObject attacker, LivingObject receiver)
        {
            if (receiver is Hostile && attacker is NPC)
            {
                receiver.CurrentHealth--;
                if (receiver.CurrentHealth == 0)
                {
                    Program.MyMap.SpawnedLivingThing[receiver.Y + Program.MyMap.MinY][receiver.X + Program.MyMap.MinX].RemoveAt(Program.MyMap.SpawnedLivingThing[receiver.Y + Program.MyMap.MinY][receiver.X + Program.MyMap.MinX].Count - 1);
                    Program.Data.MyLivingObject[receiver.Index] = null;
                }

                Program.Log.AddMessage((int)InGameLogMessageType.BadCombat, attacker.Name + " attacked " + receiver.Name);
            }
        }
        public ShieldAction(LivingObject caster, Attack id, int dir, AttackManager am)
        {
            Caster = caster;
            ID = id;
            Dir = dir;
            AM = am;

            X = Caster.X;
            Y = Caster.Y;

            Animation = new SpawnAttackAnimation(ID.Animation, X, Y, Dir, false, this);
            Attacked = false;
            Caster.CurrentDefenseAction = this;
        }
 public static List<int> KnownBluePrintForThisCharacter(LivingObject p, int cla)
 {
     List<int> KnowRecipe = new List<int>();
     KnowRecipe.Add(0);
     return KnowRecipe;
 }
        public static void DoPathFinding(LivingObject p)
        {
            if (PathThread != null && PathThread.IsAlive)
                PathThread.Abort();
            if (Program.MyMap.SpawnedSpawnableLocation[p.TargetY + Program.MyMap.MinY][p.TargetX + Program.MyMap.MinX] >= 0)
            {
                if (p is NPC)
                {
                    NPC n = (NPC)p;
                    if (n.CurrentAction == 2 && Program.MyMap.SpawnedSpawnable[Program.MyMap.SpawnedSpawnableLocation[p.TargetY + Program.MyMap.MinY][p.TargetX + Program.MyMap.MinX]] is SpawnBuildable)
                    {
                        SpawnBuildable b = (SpawnBuildable)Program.MyMap.SpawnedSpawnable[Program.MyMap.SpawnedSpawnableLocation[p.TargetY + Program.MyMap.MinY][p.TargetX + Program.MyMap.MinX]];
                        if (!b.Builded)
                        {
                        }
                    }
                    else
                    {
                        Program.Log.AddMessage((int)InGameLogMessageType.System, "Path can't be accessed");
                        return;
                    }
                }
                else
                {
                    Program.Log.AddMessage((int)InGameLogMessageType.System, "Path can't be accessed");
                    return;
                }

            }
            if (p.TargetX == p.X && p.TargetY == p.Y)
            {
                Program.Log.AddMessage((int)InGameLogMessageType.System, "Path can't be accessed");
                return;
            }
            Destination = null;
            Pathfinder = p;
            PathFound = false;
            CurrentPathFindingSession = new Dictionary<KeyValuePair<int, int>, PossiblePath>();
            NextPathFindingSession = new Dictionary<KeyValuePair<int, int>, PossiblePath>();
            OldPathFindingSession = new Dictionary<KeyValuePair<int, int>, PossiblePath>();
            CurrentPathFindingSession.Add(new KeyValuePair<int, int>(p.X, p.Y), new PossiblePath(p.X, p.Y));

            PathfindingThread();
            //ThreadStart ts = new ThreadStart(PathfindingThread);
            //PathThread = new Thread(ts);
            //PathThread.Start();
        }
Esempio n. 8
0
 public static void RemoveItemsFromInventory(LivingObject p, int id, int amount)
 {
     int still = amount;
     if (p is NPC)
     {
         NPC npc = (NPC)p;
         if (GetTotalAmountOfThisItemIn(p, id) < amount)
             return;
         for (int i = npc.Inventory.Count - 1; i >= 0; i--)
         {
             if (npc.Inventory[i] != null && npc.Inventory[i].ID == id)
             {
                 if (still - npc.Inventory[i].Amount >= 0)
                 {
                     still -= npc.Inventory[i].Amount;
                     npc.Inventory.RemoveAt(i);
                 }
                 else
                 {
                     npc.Inventory[i].Amount -= still;
                     return;
                 }
             }
             if (still == 0)
                 return;
         }
     }
 }
Esempio n. 9
0
 public void AddLivingThing(LivingObject p, int x, int y)
 {
     LivingThing.Add(p);
     SpawnedLivingThing[y + MinY][x + MinX].Add(LivingThing.Count - 1);
 }
Esempio n. 10
0
        public static List<int> KnownRecipeForThisCharacter(LivingObject p)
        {
            List<int> KnowRecipe = new List<int>();
            if (p is NPC)
            {
                NPC npc = (NPC)p;
                foreach (int r in npc.KnownRecipe)
                    KnowRecipe.Add(r);

                foreach (int k in npc.KnowledgeKnown)
                    foreach (int r in Program.Data.MyKnowledge[k].RecipeUnlock)
                        KnowRecipe.Add(r);
            }
            return KnowRecipe;
        }
Esempio n. 11
0
        public static List<int> KnownBluePrintForThisCharacter(LivingObject p, int cla)
        {
            List<int> KnowBlueprint = new List<int>();
            if (p is NPC)
            {
                NPC npc = (NPC)p;
                foreach (int b in npc.KnownBlueprint)
                    if (Program.Data.GetBuildableList()[b].Classification.Contains(cla))
                        KnowBlueprint.Add(b);

                foreach (int k in npc.KnowledgeKnown)
                    foreach (int b in Program.Data.MyKnowledge[k].BlueprintUnlock)
                        if (Program.Data.GetBuildableList()[b].Classification.Contains(cla))
                            KnowBlueprint.Add(b);
            }
            return KnowBlueprint;
        }
Esempio n. 12
0
        public static List<int> KnownBluePrintForThisCharacter(LivingObject p)
        {
            List<int> KnowBlueprint = new List<int>();
            if (p is NPC)
            {
                NPC npc = (NPC)p;
                foreach (int b in npc.KnownBlueprint)
                    KnowBlueprint.Add(b);

                foreach (int k in npc.KnowledgeKnown)
                    foreach (int b in Program.Data.MyKnowledge[k].BlueprintUnlock)
                        KnowBlueprint.Add(b);
            }
            return KnowBlueprint;
        }
Esempio n. 13
0
 public static int GetTotalAmountOfThisItemIn(LivingObject p, int id)
 {
     int total = 0;
     if (p is NPC)
     {
         NPC npc = (NPC)p;
         foreach (SpawnItems s in npc.Inventory)
             if (s != null && s.ID == id)
                 total += s.Amount;
     }
     return total;
 }
Esempio n. 14
0
 public static AttackAction CreateAttackActionFromAttack(Attack atk, LivingObject caster, AttackManager am)
 {
     AttackAction a = null;
     if (atk is BasicAttack)
         a = new BasicAttackAction(caster, atk, caster.Dir, am);
     else if (atk is ShieldAttack)
         a = new ShieldAction(caster, atk, caster.Dir, am);
     return a;
 }
Esempio n. 15
0
 public WalkAction(LivingObject p, int dir, bool change)
 {
     Person = p;
     Dir = dir;
     ChangeDir = change;
 }
Esempio n. 16
0
        public static List<int> KnownRecipeForThisCharacter(LivingObject p, int cla)
        {
            List<int> KnowRecipe = new List<int>();
            if (p is NPC)
            {
                NPC npc = (NPC)p;
                foreach (int r in npc.KnownRecipe)
                    if (Program.Data.MyItems[r].Classification.Contains(cla))
                        KnowRecipe.Add(r);

                foreach (int k in npc.KnowledgeKnown)
                    foreach (int r in Program.Data.MyKnowledge[k].RecipeUnlock)
                        if (Program.Data.MyItems[r].Classification.Contains(cla))
                            KnowRecipe.Add(r);
            }
            return KnowRecipe;
        }
Esempio n. 17
0
 public void ReceiveDamage(int damage, LivingObject caster)
 {
     if (Targeting == null)
         Targeting = caster;
     if (CurrentDefenseAction != null)
     {
         damage -= (int)(CurrentDefenseAction.ID.BaseDamage * ((float)Logic.RandomizeDamage() / 10));
         if (damage < 0)
             damage = 0;
     }
     _curHP -= damage;
     CurMap.MiniText.Add(new MiniText(damage + "", 10, (X + CurMap.MinX) * Program.Data.TileSizeX, (Y + CurMap.MinY) * Program.Data.TileSizeY - 18, 60, Color.Red, true, 0.4f));
 }