public GhostInventory(Image Slot, Image Selected, Image emptyIcon, Text Number) : base(Slot, Selected, emptyIcon, Number)
 {
     for (int i = 0; i < 10; i++)
     {
         Traps.Add(null);
     }
 }
Esempio n. 2
0
        public ICave NextCave()
        {
            var type = RandCaveType();

            switch (type)
            {
            case "Monster":
                var monster = Monsters.RandElement();
                return(new MonsterCave()
                {
                    Name = monster.Name, Atk = monster.Atk, HP = monster.HP
                });

            case "Treasure":
                var treasure = Treasures.RandElement();
                return(new TreasureCave()
                {
                    Name = treasure.Name, Golds = treasure.Golds, HP = treasure.HP
                });

            case "Trap":
                var trap = Traps.RandElement();
                return(new TrapCave()
                {
                    Name = trap.Name, Atk = trap.Atk
                });
            }

            return(null);
        }
Esempio n. 3
0
    public Coord GetRecommendRadarPosition(IEnumerable <Coord> futurRadarPositions)
    {
        var myRadarPositions = this.Radars.Select(radar => radar.Pos).ToList();

        myRadarPositions.AddRange(futurRadarPositions);

        var recommendedRadarPositions = GetRecommendedRadarPositions();

        foreach (var recommendedPosition in recommendedRadarPositions)
        {
            var positionHasAlreadyARadar = myRadarPositions.Any(p => p.Distance(recommendedPosition) == 0);
            var positionHasATrap         = Traps.Any(trap => trap.Pos.Distance(recommendedPosition) == 0);

            if (positionHasAlreadyARadar || positionHasATrap)
            {
                //Go to next
            }
            else
            {
                return(recommendedPosition);
            }
        }

        return(recommendedRadarPositions[0]);
    }
Esempio n. 4
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        Cards card = CardsDB.AllCardsInfo[this.GetComponent <Image>().sprite.name];;

        //Debug.Log(typeof());
        //panel.gameObject.SetActive(true);
        if (card.GetType() == typeof(Monsters))
        {
            Monsters monster = (Monsters)card;
            image.GetComponent <Image>().sprite = monster.CardImage;
            txt.text = monster.CardName + "\r\n" + monster.CardDesc;
        }
        else if (card.GetType() == typeof(Spells))
        {
            Spells spell = (Spells)card;
            image.GetComponent <Image>().sprite = spell.CardImage;
            txt.text = spell.CardName + "\r\n" + spell.CardDesc;
        }
        else
        {
            Traps trap = (Traps)card;
            image.GetComponent <Image>().sprite = trap.CardImage;
            txt.text = trap.CardName + "\r\n" + trap.CardDesc;
        }
    }
Esempio n. 5
0
 public void RemoveTrap(uint instanceId)
 {
     lock (TrapLock)
     {
         Traps.Remove(instanceId);
     }
 }
Esempio n. 6
0
 public void AddTrap(uint instanceId, TrapStack trap)
 {
     lock (TrapLock)
     {
         Traps.Add(instanceId, trap);
     }
 }
 /// <summary>
 /// Constructor for MessageLogged event arguments.
 /// </summary>
 /// <param name="trap">Which trap triggered the event.</param>
 /// <param name="ex">The exception that triggered the event.</param>
 /// <param name="terminating">Whether the app is being terminated by the system.</param>
 public MessageLoggedEventArgs(Traps trap, Exception ex, bool terminating)
 {
     Trap = trap;
     Ex   = ex;
     DisplayMessageBox = true;
     Terminating       = terminating;
 }
Esempio n. 8
0
        public void SafeSpots_CorrectlyCountsSafeSpotsInRow()
        {
            var sut = new Traps();

            var actual = sut.SafeSpots("..^^.");

            Assert.Equal(3, actual);
        }
Esempio n. 9
0
        public void Next_Creates_Correct_NextRow_FromInput()
        {
            var sut = new Traps();

            var next = sut.Next("..^^.");

            Assert.Equal(".^^^^", next);
        }
Esempio n. 10
0
        // This test runs correctly, but is very time-consuming.  And actually, the "test" is the
        // live test case to submit, not an actual test.
        //[Fact]
        public void ActualProblem()
        {
            var input = "^.^^^.^..^....^^....^^^^.^^.^...^^.^.^^.^^.^^..^.^...^.^..^.^^.^..^.....^^^.^.^^^..^^...^^^...^...^.";
            var sut   = new Traps();

            var rows = sut.Next(input, 399999, includefirstRow: true);

            var safeSpots = sut.SafeSpots(rows);
        }
Esempio n. 11
0
        public void Next_CreatesCorrectRows_FromInitialInput()
        {
            var sut = new Traps();

            var rows = sut.Next("..^^.", 2);

            Assert.Equal(".^^^^", rows.First());
            Assert.Equal("^^..^", rows.Last());
        }
Esempio n. 12
0
    public void ReadSpell_TrapsData()
    {
        string        conn = "URI=file:" + Application.dataPath + "/CardEditor/CDBLite.db"; //Path to database.
        IDbConnection con;

        con = (IDbConnection) new SqliteConnection(conn);
        con.Open(); //Open connection to the database.

        //newMonsters = new List<Monsters>();
        IDbCommand cmd     = con.CreateCommand();
        string     command = "Select * From Spells";

        cmd.CommandText = command;
        IDataReader rdr = cmd.ExecuteReader();

        while (rdr.Read())
        {
            string Id   = (string)rdr["Id"];
            string name = (string)rdr["Name"];
            string Desc = (string)rdr["Description"];
            if (Id[0] == '3')
            {
                Spells newCard = new Spells();

                newCard.ID       = (string)rdr["Id"];
                newCard.CardName = (string)rdr["Name"];
                newCard.CardDesc = (string)rdr["Description"];

                //newMonsters.Add(m);
                if (!AllCardsInfo.ContainsKey(newCard.ID))
                {
                    AllCardsInfo.Add(newCard.ID, newCard);
                }
            }
            else if (Id[0] == '4')
            {
                Traps newCard = new Traps();

                newCard.ID       = (string)rdr["Id"];
                newCard.CardName = (string)rdr["Name"];
                newCard.CardDesc = (string)rdr["Description"];

                //newMonsters.Add(m);
                if (!AllCardsInfo.ContainsKey(newCard.ID))
                {
                    AllCardsInfo.Add(newCard.ID, newCard);
                }
            }
        }
        rdr.Close();
        rdr = null;
        cmd.Dispose();
        cmd = null;
        con.Close();
        con = null;
    }
Esempio n. 13
0
        public void SafeSpots_LongerExample_IsCorrect()
        {
            var sut = new Traps();

            var rows = sut.Next(".^^.^.^^^^", 9, includefirstRow: true);

            var actual = sut.SafeSpots(rows);

            Assert.Equal(38, actual);
        }
Esempio n. 14
0
        public void SafeSpots_CorrectlyCountsSafeSpotsInAllRows()
        {
            var sut = new Traps();

            var rows = sut.Next("..^^.", 2, includefirstRow: true);

            var actual = sut.SafeSpots(rows);

            Assert.Equal(6, actual);
        }
Esempio n. 15
0
 public void UpgradeButton3()
 {
     if (Owner.GetType() == typeof(Traps))
     {
         Traps Temp = (Traps)Owner;
         Temp.SetCatcherRaduis(TrapTypesUpgrades.RequestUpgradeAmount(UpgradeType.CatchRaduis, Temp.Type));
     }
     else if (Owner.GetType() == typeof(TurretController))
     {
     }
 }
 /// <summary>
 /// Adds handlers for otherwise untrapped exceptions.
 /// </summary>
 /// <param name="apply"></param>
 public LastChanceHandler(Traps apply = Traps.Both)
 {
     if ((apply & Traps.Thread) == Traps.Thread)
     {
         Application.ThreadException += (s, e) => OnThreadException(s, e);
     }
     if ((apply & Traps.General) == Traps.General)
     {
         AppDomain.CurrentDomain.UnhandledException += (s, e) => OnGeneralException(s, e);
     }
 }
Esempio n. 17
0
 public void UpgradeButton2()
 {
     if (Owner.GetType() == typeof(Traps))
     {
         Traps Temp = (Traps)Owner;
         Temp.SetSucessRate(TrapTypesUpgrades.RequestUpgradeAmount(UpgradeType.CatchSuccessChance, Temp.Type));
     }
     else if (Owner.GetType() == typeof(TurretController))
     {
     }
 }
Esempio n. 18
0
        public void Next_LongerExample_IsCorrect()
        {
            var expected = new string[] { ".^^.^.^^^^", "^^^...^..^", "^.^^.^.^^.", "..^^...^^^",
                                          ".^^^^.^^.^", "^^..^.^^..", "^^^^..^^^.", "^..^^^^.^^", ".^^^..^.^^", "^^.^^^..^^" };

            var sut = new Traps();

            var actual = sut.Next(".^^.^.^^^^", 9, includefirstRow: true);

            Assert.Equal(expected, actual);
        }
Esempio n. 19
0
 public void UpgradeButton1()
 {
     if (Owner.GetType() == typeof(Traps))
     {
         Traps Temp = (Traps)Owner;
         Temp.SetAttractionTime(TrapTypesUpgrades.RequestUpgradeAmount(UpgradeType.CatchCoolDown, Temp.Type));
     }
     else if (Owner.GetType() == typeof(TurretController))
     {
     }
 }
 private void OnCollisionEnter(Collision collision)
 {
     // When ball trigger the trap, resize it.
     if (collision.gameObject.CompareTag("Trap"))
     {
         Traps trap       = collision.gameObject.GetComponent <Traps>();
         bool  randomTrap = Random.Range(0, 10) < 5;
         if (randomTrap)
         {
             StartCoroutine(trap.ScaleUp(gameObject));
         }
         else
         {
             StartCoroutine(trap.Shrinking(gameObject));
         }
     }
 }
Esempio n. 21
0
 private static void OnEndScene(EventArgs args)
 {
     try
     {
         if (loadedtrack)
         {
             Traps.Draw();
             Tracker.HPtrack();
             Tracker.track();
         }
         GanksDetector.OnEndScene();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Esempio n. 22
0
        public void Serialize(GenericWriter writer)
        {
            writer.Write(1);

            writer.Write(OnGoing);

            if (OnGoing)
            {
                writer.Write(0);
                writer.Write(StartTime);
                writer.Write(CooldownEnds);
                writer.Write(LastOccupationCheck);
                writer.Write(NextSigilSpawn);
                writer.Write(NextAnnouncement);
                writer.Write(NextAltarActivate);
                writer.Write((int)City);
                writer.Write(Sigil);
                writer.Write(VicePriest);
                writer.Write(VirtuePriest);

                writer.Write(Altars.Count);
                Altars.ForEach(altar => writer.Write(altar));

                /*writer.Write(GuildStats.Count);
                 * foreach (KeyValuePair<Guild, VvVGuildBattleStats> kvp in GuildStats)
                 * {
                 *  writer.Write(kvp.Key);
                 *  kvp.Value.Serialize(writer);
                 * }*/
                writer.Write(Teams.Count);
                foreach (BattleTeam team in Teams)
                {
                    team.Serialize(writer);
                }

                writer.Write(Traps.Count);
                Traps.ForEach(t => writer.Write(t));
            }
            else
            {
                writer.Write(1);
            }
        }
Esempio n. 23
0
    private IEnumerator BeginGame()
    {
        mazeInstance = Instantiate(mazePrefab) as Maze;
        yield return(StartCoroutine(mazeInstance.Generate()));

        inGameCanvasInstance = Instantiate(inGameCanvasPrefab) as Canvas;
        Destroy(GameObject.Find("Camera"));

        playerInstance = Instantiate(playerPrefab) as Player;
        playerInstance.SetLocation(mazeInstance.GetCell(mazeInstance.startCoords));
        yield return(0);

        endInstance = Instantiate(endPrefab) as End;
        endInstance.SetLocation(mazeInstance.GetCell(mazeInstance.endCoords));
        yield return(0);

        trapInstance = Instantiate(trapPrefab) as Traps;
        trapInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates));
        yield return(0);

        cupInstance = Instantiate(cupPrefab) as Cup;
        cupInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates));
        yield return(0);

        for (int i = 0; i < cheeseInstance.Length; i++)
        {
            cheeseInstance[i] = Instantiate(cheesePrefab) as Cheese;
            cheeseInstance[i].SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates));
        }
        yield return(0);

        for (int i = 0; i < bombInstance.Length; i++)
        {
            bombInstance[i] = Instantiate(bombPrefab) as Bombs;
        }
        bombInstance[0].SetLocation(mazeInstance.GetCell(new IntVector2(0, 0)));
        bombInstance[1].SetLocation(mazeInstance.GetCell(new IntVector2(0, mazeInstance.size.z - 1)));
        bombInstance[2].SetLocation(mazeInstance.GetCell(new IntVector2(mazeInstance.size.x - 1, 0)));
        bombInstance[3].SetLocation(mazeInstance.GetCell(new IntVector2(mazeInstance.size.x - 1, mazeInstance.size.z - 1)));
        yield return(0);

        gameState = GameState.NewPlay;
    }
Esempio n. 24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Objects"/> class.
        /// </summary>
        internal Objects()
        {
            this.Buildings  = new Buildings(this);
            this.Buildings2 = new Buildings(this, true);

            this.Obstacles  = new Obstacles(this);
            this.Obstacles2 = new Obstacles(this, true);

            this.Traps  = new Traps(this);
            this.Traps2 = new Traps(this, true);

            this.Decos  = new Decos(this);
            this.Decos2 = new Decos(this, true);

            this.VillageObjects = new VillageObjects(this);

            this.Collider  = new Collider(this);
            this.Collider2 = new Collider(this);
        }
Esempio n. 25
0
 public static void Load()
 {
     Gapcloser.OnGapcloser            += Gapcloser_OnGapCloser;
     Interrupter.OnInterruptableSpell += Interrupter_OnInterruptableSpell;
     Orbwalker.OnPostAttack           += Orbwalker_OnPostAttack;
     Obj_AI_Base.OnBasicAttack        += Obj_Ai_Base_OnBasicAttack;
     Obj_AI_Base.OnProcessSpellCast   += Obj_AI_Base_OnProcessSpell;
     Obj_AI_Base.OnBuffGain           += Obj_AI_Base_OnBuffGain;
     Obj_AI_Base.OnSpellCast          += Obj_AI_Base_OnSpellCast;
     GameObject.OnCreate += GameObject_OnCreate;
     Game.OnTick         += Game_OnTick;
     Game.OnUpdate       += Game_OnUpdate;
     Player.OnIssueOrder += Player_OnIssueOrder;
     Drawing.OnDraw      += OnDraw;
     Mechanics.LoadFlash();
     Traps.Load();
     Turrets.Load();
     Evade.EvadeHelper.OnLoad();
 }
Esempio n. 26
0
    public void OnPointerClick(PointerEventData eventData)
    {
        clicked = true;
        lerp    = 0;
        inst    = Instantiate(Card, this.transform.position, this.transform.rotation) as GameObject;
        inst.transform.SetParent(Hand.transform.parent);
        float rate = 68 / ScaleX;

        inst.GetComponent <RectTransform>().localScale = new Vector3(68, ScaleY * rate, ScaleZ * rate);
        Panel.transform.SetParent(inst.transform);


        Cards c = CardsDB.PlayerOne.RandomOrderPlayingCard[CardsDB.PlayerOne.RandomOrderPlayingCard.Count - 1];

        print(c.CardName);
        CardsDB.PlayerOne.RandomOrderPlayingCard.RemoveAt(CardsDB.PlayerOne.RandomOrderPlayingCard.Count - 1);
        //print(c.CardName);
        Debug.Log(c.GetType().ToString());
        if (c.GetType() == typeof(Monsters))
        {
            //Debug.Log("HERE");
            Monsters newMonster = new Monsters((Monsters)c);
            Debug.Log(newMonster.CardImage.name);
            inst.transform.GetChild(0).GetComponent <Image>().sprite = newMonster.CardImage;
            inst.transform.GetChild(1).GetComponent <Text>().text    = "ATK/" + newMonster.AttackPoints + "   " + "DEF/" + newMonster.DefencePoints;
        }
        else if (c.GetType() == typeof(Spells))
        {
            Spells newMonster = new Spells((Spells)c);
            Debug.Log(newMonster.CardImage.name);
            inst.transform.GetChild(0).GetComponent <Image>().sprite = newMonster.CardImage;
            //inst.transform.GetChild(1).GetComponent<Text>().text = "ATK/" + newMonster.AttackPoints + "   " + "DEF/" + newMonster.DefencePoints;
        }
        else if (c.GetType() == typeof(Traps))
        {
            Traps newMonster = new Traps((Traps)c);
            Debug.Log(newMonster.CardImage.name);
            inst.transform.GetChild(0).GetComponent <Image>().sprite = newMonster.CardImage;
            //inst.transform.GetChild(1).GetComponent<Text>().text = "ATK/" + newMonster.AttackPoints + "   " + "DEF/" + newMonster.DefencePoints;
        }
    }
Esempio n. 27
0
        private void HandlePlayerMove()
        {
            var currentTrap = Traps.FirstOrDefault(trap => trap.Position == Player.Position);

            if (currentTrap != null && currentTrap.IsActive)
            {
                HitPlayer(currentTrap.Damage);
                _gameViewer.DisplayField(_dataToView);
                Console.WriteLine($"Boom! You've lost {currentTrap.Damage} hp!\nPress any key to continue");
                Console.ReadKey();
                DeactivateTrap(currentTrap);
            }

            if (Player.Hp <= 0)
            {
                FinishGameWithMessage("loose");
            }

            if (Player.Position == Princes.Position)
            {
                FinishGameWithMessage("win");
            }
        }
Esempio n. 28
0
    private void setActualEnemy()
    {
        RaycastHit hit;

        if (Physics.Raycast(fromJoint.transform.position, (toJoint.transform.position - fromJoint.transform.position), out hit))
        {
            if (hit.transform.tag == "Enemy")
            {
                Traps startTrap = fromJoint.GetComponent <JointInfo>().activeTrap.GetComponent <Traps>();
                Traps toTrap    = toJoint.GetComponent <JointInfo>().activeTrap.GetComponent <Traps>();

                if (hit.distance < startTrap.range)
                {
                    fromJoint.GetComponent <JointInfo>().activeTrap.GetComponent <Traps>().enemy = hit.transform.gameObject;
                }

                if (Vector3.Distance(hit.transform.position, toJoint.transform.position) < toTrap.range)
                {
                    toJoint.GetComponent <JointInfo>().activeTrap.GetComponent <Traps>().enemy = hit.transform.gameObject;
                }
            }
        }
    }
Esempio n. 29
0
        public void EndBattle()
        {
            EndTimer();

            if (Region is GuardedRegion)
            {
                ((GuardedRegion)Region).Disabled = false;
            }

            CooldownEnds = DateTime.UtcNow + TimeSpan.FromMinutes(Cooldown);
            ViceVsVirtueSystem.Instance.OnBattleEnd();

            foreach (VvVAltar altar in Altars)
            {
                if (!altar.Deleted)
                {
                    altar.Delete();
                }
            }

            foreach (VvVTrap trap in Traps)
            {
                if (!trap.Deleted)
                {
                    trap.Delete();
                }
            }

            foreach (CannonTurret turret in Turrets)
            {
                if (!turret.Deleted)
                {
                    turret.Delete();
                }
            }

            if (VicePriest != null)
            {
                VicePriest.Delete();
                VicePriest = null;
            }

            if (VirtuePriest != null)
            {
                VirtuePriest.Delete();
                VirtuePriest = null;
            }

            if (Sigil != null)
            {
                Sigil.Delete();
                Sigil = null;
            }

            Guild leader = GetLeader();

            foreach (Mobile m in this.Region.GetEnumeratedMobiles())
            {
                Guild g = m.Guild as Guild;

                if (leader != null && (g == leader || leader.IsAlly(g)))
                {
                    System.AwardPoints(m, WinSilver + (OppositionCount(g) * 50), message: false);
                }
            }

            SendBattleStatsGump();

            System.SendVvVMessage(1154722); // A VvV battle has just concluded. The next battle will begin in less than five minutes!

            Altars.Clear();
            GuildStats.Clear();
            KillCooldown.Clear();
            Participants.Clear();
            Participants.TrimExcess();
            Messages.Clear();
            Messages.TrimExcess();
            Traps.Clear();
            Traps.TrimExcess();
            Warned.Clear();
            Warned.TrimExcess();
            Turrets.Clear();
            Turrets.TrimExcess();

            if (Region is GuardedRegion)
            {
                ((GuardedRegion)Region).Disabled = false;
            }

            OnGoing = false;

            NextSigilSpawn      = DateTime.MinValue;
            LastOccupationCheck = DateTime.MinValue;
            NextAnnouncement    = DateTime.MinValue;
            StartTime           = DateTime.MinValue;
            NextAltarActivate   = DateTime.MinValue;
            ManaSpikeEndEffects = DateTime.MinValue;
            NextManaSpike       = DateTime.MinValue;
        }
Esempio n. 30
0
        internal Data Create(Row _Row)
        {
            Data _Data;

            switch ((Gamefile)Index)
            {
            case Gamefile.Buildings:
                _Data = new Buildings(_Row, this);
                break;

            case Gamefile.Resources:
                _Data = new CSV_Logic.Resource(_Row, this);
                break;

            case Gamefile.Characters:
                _Data = new Characters(_Row, this);
                break;

            case Gamefile.Obstacles:
                _Data = new Obstacles(_Row, this);
                break;

            case Gamefile.Experience_Levels:
                _Data = new Experience_Levels(_Row, this);
                break;

            case Gamefile.Traps:
                _Data = new Traps(_Row, this);
                break;

            case Gamefile.Globals:
                _Data = new Globals(_Row, this);
                break;

            case Gamefile.Npcs:
                _Data = new Npcs(_Row, this);
                break;

            case Gamefile.Decos:
                _Data = new Decos(_Row, this);
                break;

            case Gamefile.Missions:
                _Data = new Missions(_Row, this);
                break;

            case Gamefile.Spells:
                _Data = new Spells(_Row, this);
                break;

            case Gamefile.Heroes:
                _Data = new Heroes(_Row, this);
                break;

            case Gamefile.Leagues:
                _Data = new Leagues(_Row, this);
                break;

            case Gamefile.Variables:
                _Data = new Variables(_Row, this);
                break;

            case Gamefile.Village_Objects:
                _Data = new Village_Objects(_Row, this);
                break;

            /*case 2:
             *  _Data = new Locales(_Row, this);
             *  break;
             * case 3:
             *  _Data = new Resources(_Row, this);
             *  break;
             * case 4:
             *  _Data = new Characters(_Row, this);
             *  break;
             * // case 5: Animation
             * case 6:
             *  _Data = new Projectiles(_Row, this);
             *  break;
             * case 7:
             *  _Data = new Building_Classes(_Row, this);
             *  break;
             * case 8:
             *  _Data = new Obstacles(_Row, this);
             *  break;
             * case 9:
             *  _Data = new Effects(_Row, this);
             *  break;
             * // case 10: Particle Emitters
             * case 11:
             *  _Data = new Experience_Levels(_Row, this);
             *  break;
             * case 12:
             *  _Data = new Traps(_Row, this);
             *  break;
             * case 13:
             *  _Data = new Alliance_Badges(_Row, this);
             *  break;
             * case 14:
             *  _Data = new Globals(_Row, this);
             *  break;
             * // case 15: TownHall Levels
             * case 16:
             *  _Data = new Alliance_Portal(_Row, this);
             *  break;
             * case 17:
             *  _Data = new Npcs(_Row, this);
             *  break;
             * case 18:
             *  _Data = new Decos(_Row, this);
             *  break;
             * // case 19: Resource Packs
             * case 20:
             *  _Data = new Shields(_Row, this);
             *  break;
             * // case 22: Billing Packages
             * case 23:
             *  _Data = new Achievements(_Row, this);
             *  break;
             * // case 24: Credits
             * // case 25: Faq
             * case 26:
             *  _Data = new Spells(_Row, this);
             *  break;
             * // case 27: Hints
             * case 28:
             *  _Data = new Heroes(_Row, this);
             *  break;
             * case 29:
             *  _Data = new Leagues(_Row, this);
             *  break;
             *
             * case 37:
             *  _Data = new Variables(_Row, this);
             *  break;
             */
            default:
            {
                _Data = new Data(_Row, this);
                break;
            }
            }

            return(_Data);
        }