コード例 #1
0
        public int dropAmount()
        {
            if (!bItemIsStackable)
            {
                if (GamePlayUtility.randomChance() < chanceToDrop)
                {
                    return(1);
                }
                return(-1);
            }
            else
            {
                if (!dropStackChanceStack)
                {
                    return(GamePlayUtility.Randomize(minDrop, maxDrop));
                }

                int amount = -1;
                while (amount < maxDrop && GamePlayUtility.randomChance() < chanceToDrop)
                {
                    if (amount == -1)
                    {
                        amount = minDrop;
                    }
                    amount++;
                }
                return(amount);
            }
        }
コード例 #2
0
        public TBAGW.EnemyAIInfo ToEnemy(TBAGW.MapZone mz, List <BasicTile> playerZone)
        {
            TBAGW.EnemyAIInfo temp = mz.zoneEncounterInfo.enemies.Find(e => e.enemyName.Equals(name, StringComparison.OrdinalIgnoreCase) ||
                                                                       name.Equals(e.enemyCharBase.CharacterName, StringComparison.OrdinalIgnoreCase) ||
                                                                       name.Equals(e.enemyCharBase.displayName, StringComparison.OrdinalIgnoreCase));

            if (temp == null)
            {
                return(null);
            }

            bool      bGenerateLocation = true;
            Vector2   pos  = new Vector2(location.x * 64, location.y * 64);
            BasicTile tile = new BasicTile();

            if (mz.Contains(pos))
            {
                tile = GameProcessor.loadedMap.possibleTilesGameZoneForEnemyINITIALIZATION(mz.zoneTiles).Except(playerZone).ToList().Find(t => t.positionGrid == new Vector2(location.x, location.y));
                if (tile != default(TBAGW.BasicTile))
                {
                    Console.WriteLine("From LuaScriptBattle, script enemy has correct spawn location!");
                    bGenerateLocation = false;

                    //int randomNum = GamePlayUtility.Randomize(0, temp.Count);
                    //var randomTile = temp[randomNum];
                }
            }

            if (bGenerateLocation)
            {
                Console.WriteLine("From LuaScriptBattle, script enemy has incorrect spawn location!");
                var tiles = GameProcessor.loadedMap.possibleTilesGameZoneForEnemyINITIALIZATION(mz.zoneTiles).Except(playerZone).ToList();
                if (tiles.Count < PlayerSaveData.heroParty.Count)
                {
                    return(null);
                }
                int randomNum = GamePlayUtility.Randomize(0, tiles.Count);
                tile = tiles[randomNum];
            }

            CombatProcessor.encounterEnemies.Add(temp.enemyCharBase);
            CombatProcessor.encounterEnemies.Last().spriteGameSize = new Rectangle(((Rectangle)tile.mapPosition).X, ((Rectangle)tile.mapPosition).Y, ((Rectangle)tile.mapPosition).Width, ((Rectangle)tile.mapPosition).Height);

            CombatProcessor.encounterEnemies.Last().position      = CombatProcessor.encounterEnemies.Last().spriteGameSize.Location.ToVector2();
            CombatProcessor.encounterEnemies.Last().rotationIndex = rot % 4;
            CombatProcessor.encounterEnemies.Last().UpdatePosition();

            //temp.enemyCharBase.spriteGameSize = new Rectangle(((Rectangle)tile.mapPosition).X, ((Rectangle)tile.mapPosition).Y, ((Rectangle)tile.mapPosition).Width, ((Rectangle)tile.mapPosition).Height);
            //item.spriteGameSize.Width = 64;
            //item.spriteGameSize.Height = 64;
            //temp.enemyCharBase.spriteGameSize = new Rectangle(((Rectangle)tile.mapPosition).X, ((Rectangle)tile.mapPosition).Y, ((Rectangle)tile.mapPosition).Width, ((Rectangle)tile.mapPosition).Height);
            //temp.enemyCharBase.rotationIndex = rot % 4;
            //temp.enemyCharBase.position = temp.enemyCharBase.spriteGameSize.Location.ToVector2();
            //GameProcessor.encounterEnemies = enemies;
            //CombatProcessor.encounterEnemies.Add(temp.enemyCharBase);
            //CombatProcessor.encounterEnemies.Last().spriteGameSize = new Rectangle(((Rectangle)tile.mapPosition).X, ((Rectangle)tile.mapPosition).Y, ((Rectangle)tile.mapPosition).Width, ((Rectangle)tile.mapPosition).Height);
            return(null);
        }
コード例 #3
0
ファイル: OthelloGame.cs プロジェクト: lotuzz/Reversi-Game
        //Event Handler
        private async void _GetMove(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            GamePlayUtility.MakeMove(_CurrentTurn, btn);
            await BoardUtility.TryFlipEnemyDisks(_Board, _CurrentTurn, _Enemy(), _Index(btn));

            _UpdateDisplayScore();
            await _NextTurn();
        }
コード例 #4
0
 public static LuaPoint RandomMapPosition()
 {
     if (CombatProcessor.zoneTiles.Count != 0)
     {
         BasicTile randomTile = CombatProcessor.zoneTiles[GamePlayUtility.Randomize(0, CombatProcessor.zoneTiles.Count - 1)];
         LuaPoint  p          = new LuaPoint(randomTile.positionGrid.X, randomTile.positionGrid.Y);
         return(p);
     }
     return(null);
 }
コード例 #5
0
 public bool CauseEffect()
 {
     if (effectChance != 0)
     {
         int temp = GamePlayUtility.Randomize(0, effectChanceUB);
         if (temp <= effectChance)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #6
0
 public bool CauseModifier()
 {
     if (modifierChance != 0)
     {
         int temp = GamePlayUtility.Randomize(0, modifierChanceUB);
         if (temp <= modifierChance)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #7
0
        internal static void Generate(int rMax = 6)
        {
            flashes.Clear();
            int amount = GamePlayUtility.Randomize(2, rMax);

            for (int i = 0; i < amount - 1; i++)
            {
                int l    = GamePlayUtility.Randomize(128, 256);
                int ttnf = GamePlayUtility.Randomize(96, 1048);
                flashes.Add(new Flash(l, ttnf, false, Color.LightGray));
            }
            flashes.Add(new Flash(GamePlayUtility.Randomize(640, 1200), 0, true, Color.LightYellow));
        }
コード例 #8
0
        static public void Start(MapRegion r, MapZone z, List <BasicTile> startZone)
        {
            //GameProcessor.encounterEnemies.Clear();
            enemies.Clear();
            region = r;
            zone   = z;
            int min = z.zoneEncounterInfo.packSizeMin;
            int max = z.zoneEncounterInfo.packSizeMax;

            if (!cSpawnAmount.Equals(default(customSpawnAmount)))
            {
                min = cSpawnAmount.min;
                max = cSpawnAmount.max;
            }
            int amountOfEnemies = GamePlayUtility.Randomize(min, max);
            var spawnList       = new List <TBAGW.KeyValuePair <int, EnemyAIInfo> >();
            int index           = 0;

            foreach (var item in zone.zoneEncounterInfo.enemySpawnChance)
            {
                spawnList.Add(new TBAGW.KeyValuePair <int, EnemyAIInfo>(item, z.zoneEncounterInfo.enemies[index]));
                index++;
            }
            spawnList = spawnList.OrderBy(ele => ele.Key).ToList();

            while (enemies.Count < amountOfEnemies)
            {
                int maxTries   = spawnList.Count;
                int currentTry = 0;
                while (currentTry < maxTries)
                {
                    int percentage = GamePlayUtility.Randomize(0, 100);
                    if (spawnList[currentTry].Key > percentage)
                    {
                        // enemies.Add(zone.zoneEncounterInfo.enemies[currentTry].ShallowCopy());
                        enemies.Add(spawnList[currentTry].Value.enemyCharBase);
                    }
                    currentTry++;
                }
            }

            //Console.WriteLine("I think I have a random list of enemies ready... Not sure though...");

            //  GenerateLocations();
            NewGenerateLocationsCode(startZone);
            // return enemies;
        }
コード例 #9
0
        internal static BaseCharacter SelectTargetBasedOnBehaviour(List <KeyValuePair <BaseCharacter, int> > lbci)
        {
            int randomnessFactor = 10;
            int biggestThread    = lbci.Max(bci => bci.Value);
            List <BaseCharacter> characterToChooseFrom = new List <BaseCharacter>();

            foreach (var item in lbci)
            {
                if ((item.Value + randomnessFactor) >= biggestThread)
                {
                    characterToChooseFrom.Add(item.Key);
                }
            }



            return(characterToChooseFrom[GamePlayUtility.Randomize(0, characterToChooseFrom.Count)]);
        }
コード例 #10
0
        public void ReloadTextures()
        {
            try
            {
                particleBaseTex = Game1.contentManager.Load <Texture2D>(particleBaseTexSource);
            }
            catch
            {
            }
            try
            {
                particleTex = Game1.contentManager.Load <Texture2D>(particleTexSource);
            }
            catch
            {
            }

            nextParticleSpawnsIn = GamePlayUtility.Randomize(spawnTimeMin, spawnTimeMax);
        }
コード例 #11
0
        private static void NewGenerateLocationsCode(List <BasicTile> startZonePlayer)
        {
            foreach (var item in enemies)
            {
                var temp       = GameProcessor.loadedMap.possibleTilesGameZoneForEnemyINITIALIZATION(CombatProcessor.zoneTiles).Except(startZonePlayer).ToList();
                int randomNum  = GamePlayUtility.Randomize(0, temp.Count);
                var randomTile = temp[randomNum];
                item.spriteGameSize        = new Rectangle(((Rectangle)randomTile.mapPosition).X, ((Rectangle)randomTile.mapPosition).Y, ((Rectangle)randomTile.mapPosition).Width, ((Rectangle)randomTile.mapPosition).Height);
                item.spriteGameSize.Width  = 64;
                item.spriteGameSize.Height = 64;
                item.rotationIndex         = GamePlayUtility.Randomize(0, 4);
                item.position = item.spriteGameSize.Location.ToVector2();
                //GameProcessor.encounterEnemies = enemies;
                CombatProcessor.encounterEnemies.Add(item);
            }

            LootGenerator.Generate(CombatProcessor.encounterEnemies);
            // GameProcessor.encounterEnemies = enemies;
            // CombatProcessor.encounterEnemies = enemies;
        }
コード例 #12
0
        public LuaCharacterInfo RandomMember(bool bAllowDeadHeroes = false)
        {
            LuaCharacterInfo lci = new LuaCharacterInfo();

            if (bIsPlayer)
            {
                if (bAllowDeadHeroes)
                {
                    return(TBAGW.PlayerSaveData.heroParty[GamePlayUtility.Randomize(0, TBAGW.PlayerSaveData.heroParty.Count - 1)].toCharInfo());
                }
                else
                {
                    var charsAlive = TBAGW.PlayerSaveData.heroParty.FindAll(h => h.IsAlive());
                    return(charsAlive[GamePlayUtility.Randomize(0, charsAlive.Count - 1)].toCharInfo());
                }
            }
            else
            {
                var charsAlive = charactersInGroup.FindAll(h => h.IsAlive());
                return(charsAlive[GamePlayUtility.Randomize(0, charsAlive.Count - 1)].toCharInfo());
            }
        }
コード例 #13
0
        public void Update(GameTime gt)
        {
            spawnTimer += gt.ElapsedGameTime.Milliseconds;

            if (spawnTimer > nextParticleSpawnsIn)
            {
                nextParticleSpawnsIn = GamePlayUtility.Randomize(spawnTimeMin, spawnTimeMax);
                spawnTimer           = 0;
                for (int i = 0; i < particleAmountSpawn; i++)
                {
                    GenerateParticle();
                }
            }

            foreach (var particle in livingParticles)
            {
                particle.Update(gt);
            }

            livingParticles.RemoveAll(p => !p.bIsAlive);

            try
            {
                baseFrameTimePassed += gt.ElapsedGameTime.Milliseconds;
                if (baseFrameTimePassed > baseFrameTimer)
                {
                    baseFrameTimePassed = 0;
                    baseFrameIndex++;
                }

                if (baseFrameIndex > particleBaseFrames.Count - 1)
                {
                    baseFrameIndex = 0;
                }
            }
            catch
            {
            }
        }
コード例 #14
0
        private void ResetAndChangeGroup()
        {
            bIsCompleted = false;
            foreach (var item in groupTurnSet)
            {
                item.bIsCompleted = false;
            }

            if (bIsPlayerTurnSet)
            {
                BattleScriptHandler.Execute(LUA.LuaBScriptEvent.EventType.postPT, this.toLuaTurnSetInfo());
            }
            else
            {
                BattleScriptHandler.Execute(LUA.LuaBScriptEvent.EventType.postET, this.toLuaTurnSetInfo());
            }


            EncounterInfo.ChangeGroup();

            randomEnemy = GamePlayUtility.Randomize(0, CombatProcessor.heroCharacters.Count - 1);
        }
コード例 #15
0
ファイル: OthelloGame.cs プロジェクト: lotuzz/Reversi-Game
        private async Task _NextTurn()
        {
            BoardUtility.DisablePanelAndResetText(_Board);
            if (!GamePlayUtility.IsPossibleToMove(_Board, _Enemy()))
            {
                if (!GamePlayUtility.IsPossibleToMove(_Board, _CurrentTurn))
                {
                    _GameOver();
                    return;
                }

                MessageBox.Show($"[{_Enemy().PlayerSide.Name}] Player can't move. [{_CurrentTurn.PlayerSide.Name}] Turn", "Game Notification");
                return;
            }

            _CurrentTurn          = _Enemy();
            _PlayerTurnLabel.Text = _CurrentTurn.PlayerSide.Name;
            if (_CurrentTurn is GreedyAI player)
            {
                await player.AutoMove(_Board);
            }
            return;
        }
コード例 #16
0
        static public void DrawWithNoEffects(SpriteBatch sb, RenderTarget2D r2d)
        {
            sb.End();
            sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, SceneUtility.transform);

            Rectangle renderBounds = new Rectangle(r2d.Bounds.X, r2d.Bounds.Y + ZoomHorizontalModifier, r2d.Bounds.Width, r2d.Bounds.Height - 2 * ZoomHorizontalModifier);

            switch (currentEffect)
            {
            case Effects.None:


                sb.Draw(r2d, renderBounds, renderBounds, Color.White);
                break;

            case Effects.Conversation:
                sb.Draw(r2d, renderBounds, renderBounds, Color.White);
                break;

            case Effects.RegionName:
                sb.Draw(r2d, renderBounds, renderBounds, Color.White);
                break;

            case Effects.Shake:
                renderBounds.X += GamePlayUtility.Randomize(-35, 35);
                renderBounds.Y += GamePlayUtility.Randomize(-35, 35);

                sb.Draw(r2d, renderBounds, new Rectangle(r2d.Bounds.X, r2d.Bounds.Y + ZoomHorizontalModifier, r2d.Bounds.Width, r2d.Bounds.Height - 2 * ZoomHorizontalModifier), Color.White);
                break;

            default:
                break;
            }

            sb.End();
        }
コード例 #17
0
        private void WanderLogic()
        {
            List <BasicTile> possibleMovement = new List <BasicTile>();

            possibleMovement.AddRange(currentTimeCommand.NPCArea.FindAll(t => t.distanceCoordsFrom(currentTimeCommand.NPCArea[currentTimeCommand.areaIndex].positionGrid * 64) == 1));
            currentTimeCommand.areaIndex = currentTimeCommand.NPCArea.IndexOf(possibleMovement[GamePlayUtility.Randomize(0, possibleMovement.Count)]);
            //moveHandler.Start(currentTimeCommand.NPCArea[currentTimeCommand.areaIndex], this);
        }
コード例 #18
0
        private void GenerateParticle()
        {
            int randomLT    = GamePlayUtility.Randomize(lifeTimeMin, lifeTimeMax);
            int randomFrame = 0;

            if (bRandomFrameStart)
            {
                try
                {
                    randomFrame = GamePlayUtility.Randomize(0, particleFrames.Count - 1);
                }
                catch
                {
                }
            }
            float randomRotation      = 0f;
            float randomRotationSpeed = 0f;

            randomRotation = GamePlayUtility.ExpertRandomize(spawnAngleMin, spawnAngleMax);
            if (spawnAngleMin == spawnAngleMax)
            {
                randomRotation = spawnAngleMin;
            }
            if (particleRotationSpeedMax != 0f)
            {
                randomRotation      = GamePlayUtility.ExpertRandomize(0, (float)(2 * Math.PI));
                randomRotationSpeed = GamePlayUtility.ExpertRandomize(particleRotationSpeedMin, particleRotationSpeedMax);
            }
            float randomScale         = GamePlayUtility.ExpertRandomize(scaleMin, scaleMax);
            float randomVelocity      = GamePlayUtility.ExpertRandomize(particleMinVelocity, particleMaxVelocity);
            float randomSpawnRotation = GamePlayUtility.ExpertRandomize(spawnAngleMin, spawnAngleMax);
            int   randomX             = 0;
            int   randomY             = 0;

            if (particleStyle == ParticleStyle.Rain || true)
            {
                randomX = GamePlayUtility.Randomize(0, spawnArea.X);
                randomY = GamePlayUtility.Randomize(0, spawnArea.Y);
            }
            Point    randomSpawnPoint = new Point(randomX, randomY) + spawnPosition;
            Particle temp             = new Particle(randomLT, randomFrame, randomRotation, randomRotationSpeed, randomScale, randomVelocity, randomSpawnRotation, particleStyle, randomSpawnPoint, this);

            switch (particleStyle)
            {
            case ParticleStyle.Rain:
                break;

            case ParticleStyle.Explosion:
                break;

            case ParticleStyle.Implosion:
                break;

            case ParticleStyle.Twister:
                float randomRadius  = GamePlayUtility.ExpertRandomize(radiusMin, radiusMax);
                float randomCircleX = GamePlayUtility.ExpertRandomize(-radiusMax, radiusMax);
                float circleY       = (float)Math.Sqrt((randomRadius * randomRadius) - (randomCircleX * randomCircleX));
                temp.TurnParticleInTwister(new Vector2(randomCircleX, circleY), pivot);
                break;

            default:
                break;
            }
            livingParticles.Add(temp);
        }
コード例 #19
0
        static public List <KeyValuePair <BaseCharacter, int> > ProcessBehaviour(BaseCharacter bc, List <BaseCharacter> lbc)
        {
            List <KeyValuePair <BaseCharacter, int> > charsAndThreat = new List <KeyValuePair <BaseCharacter, int> >();
            int             randomNum = GamePlayUtility.Randomize(0, lbc.Count);
            AIBehaviourType Behaviour = (bc).Behaviour;

            if (lbc.Count != 0 && CombatProcessor.heroCharacters.Contains(lbc[0]))
            {
                foreach (var character in lbc)
                {
                    int threat = character.returnTotalThreat();


                    float modifier = 1.3f;

                    switch (Behaviour)
                    {
                    case AIBehaviourType.Neutral:
                        break;

                    case AIBehaviourType.Berserk:
                        int maxSTR = lbc.Max(c => c.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.STR]);
                        if (character.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.STR] == maxSTR)
                        {
                            threat  = (int)(modifier * threat);
                            threat += 10;
                        }
                        break;

                    case AIBehaviourType.Magic_Hater:
                        if (character.CCC.equippedClass.classType == BaseClass.CLASSType.CASTER)
                        {
                            threat  = (int)(modifier * threat);
                            threat += 10;
                        }
                        break;

                    case AIBehaviourType.Random:
                        if (lbc.IndexOf(character) == randomNum)
                        {
                            threat  = (int)(modifier * threat);
                            threat += 10;
                        }
                        break;

                    case AIBehaviourType.Challenger:
                        int maxDEF = lbc.Max(c => c.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.DEF]);
                        if (character.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.DEF] == maxDEF)
                        {
                            threat  = (int)(modifier * threat);
                            threat += 10;
                        }
                        break;

                    case AIBehaviourType.Coward:
                        maxSTR = lbc.Max(c => c.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.STR]);
                        if (character.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.STR] == maxSTR)
                        {
                            threat  = (int)((0.8f) * threat);
                            threat -= 7;
                        }
                        break;

                    case AIBehaviourType.Avenger:
                        int maxKD = lbc.Max(c => BattleStats.getKDFromBattle(c));
                        if (BattleStats.getKDFromBattle(character) == maxKD)
                        {
                            threat  = (int)((modifier) * threat);
                            threat += 10;
                        }
                        break;

                    case AIBehaviourType.Ambitious:
                        int maxHP = lbc.Max(c => c.trueSTATChart().currentPassiveStats[(int)STATChart.ACTIVESTATS.HP]);
                        if (character.trueSTATChart().currentPassiveStats[(int)STATChart.ACTIVESTATS.HP] == maxHP)
                        {
                            threat  = (int)((modifier) * threat);
                            threat += 10;
                        }
                        break;

                    case AIBehaviourType.Finisher:
                        int minHP = lbc.Min(c => c.trueSTATChart().currentPassiveStats[(int)STATChart.ACTIVESTATS.HP]);
                        if (character.trueSTATChart().currentPassiveStats[(int)STATChart.ACTIVESTATS.HP] == minHP)
                        {
                            threat  = (int)((modifier) * threat);
                            threat += 10;
                        }
                        break;

                    case AIBehaviourType.Intellect_Hater:
                        int maxINT = lbc.Max(c => c.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.INT]);
                        if (character.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.INT] == maxINT)
                        {
                            threat  = (int)(modifier * threat);
                            threat += 10;
                        }
                        break;

                    default:
                        break;
                    }
                    charsAndThreat.Add(new KeyValuePair <BaseCharacter, int>(character, threat));
                }
            }
            else
            {
                List <BaseCharacter> charactersThatNeedHealing = lbc.FindAll(h => h.NeedsHealing());

                if (charactersThatNeedHealing.Count == 0)
                {
                    //FILL SUPPORTLOGIC HERE LATER
                    foreach (var character in lbc)
                    {
                        charsAndThreat.Add(new KeyValuePair <BaseCharacter, int>(character, GamePlayUtility.Randomize(0, 20)));
                    }
                }
                else
                {
                    foreach (var character in charactersThatNeedHealing)
                    {
                        charsAndThreat.Add(new KeyValuePair <BaseCharacter, int>(character, GamePlayUtility.Randomize(character.HealingRequired, character.HealingRequired * 2)));
                    }
                }
            }



            return(charsAndThreat);
        }
コード例 #20
0
        private void LastDitchEffortAttack()
        {
            BasicAbility testAbility = currentEnemy.character.CCC.AIDefaultAttack.Clone();

            testAbility.abilityCooldownTimer = 0;

            if (currentEnemy.character.AbilityList().Find(abi => abi.abilityIdentifier == testAbility.abilityIdentifier) == null)
            {
                currentEnemy.character.CCC.equippedClass.classAbilities.Add(testAbility);
            }

            List <BasicAbility> possibleAbilities = new List <BasicAbility>();

            foreach (var ability in currentEnemy.character.AbilityList())
            {
                if (ability.IsAbilityAvailable(currentEnemy.character.trueSTATChart()))
                {
                    possibleAbilities.Add(ability);
                }
            }

            foreach (var item in possibleAbilities)
            {
                if (GamePlayUtility.randomChance() < item.castChance)
                {
                    testAbility = item;
                    break;
                }
            }

            if (testAbility.IsAbilityAvailable(currentEnemy.character.trueSTATChart()))
            {
                List <BaseCharacter> allTargetableCharactersInRange = new List <BaseCharacter>();
                if (testAbility.abilityType == (int)BasicAbility.ABILITY_TYPE.ATTACK)
                {
                    foreach (var item in currentEnemy.parentTS.targetGroups)
                    {
                        foreach (var character in item.charactersInGroup)
                        {
                            if (testAbility.abilityCanHitTargetInRange(currentEnemy.character, character))
                            {
                                allTargetableCharactersInRange.Add(character);
                            }
                        }
                    }
                    if (allTargetableCharactersInRange.Count > 0)
                    {
                        // BattleGUI.AIStart(currentEnemy.character, allTargetableCharactersInRange[GamePlayUtility.Randomize(0, allTargetableCharactersInRange.Count)], currentEnemy.character.AbilityList().IndexOf(testAbility));
                        GameProcessor.StartBattleSoon(currentEnemy.character, allTargetableCharactersInRange[GamePlayUtility.Randomize(0, allTargetableCharactersInRange.Count)], currentEnemy.character.AbilityList().IndexOf(testAbility));
                    }
                }
                else if (testAbility.abilityType == (int)BasicAbility.ABILITY_TYPE.SUPPORT)
                {
                    foreach (var character in currentEnemy.parentTS.charactersInGroup)
                    {
                        if (character == currentEnemy.character)
                        {
                        }
                        if (character != currentEnemy.character && testAbility.abilityCanHitTargetInRange(currentEnemy.character, character))
                        {
                            allTargetableCharactersInRange.Add(character);
                        }
                    }

                    if (allTargetableCharactersInRange.Count > 0)
                    {
                        //BattleGUI.AIStart(currentEnemy.character, allTargetableCharactersInRange[GamePlayUtility.Randomize(0, allTargetableCharactersInRange.Count)], currentEnemy.character.AbilityList().IndexOf(testAbility));
                        GameProcessor.StartBattleSoon(currentEnemy.character, allTargetableCharactersInRange[GamePlayUtility.Randomize(0, allTargetableCharactersInRange.Count)], currentEnemy.character.AbilityList().IndexOf(testAbility));
                    }
                }
            }
            if (!BattleGUI.bIsRunning)
            {
                currentEnemy.character.attackedAsAI = true;
            }
        }
コード例 #21
0
        internal void UpdateEnemyLogic(CharacterTurn gts)
        {
            if (!PathMoveHandler.bIsBusy)
            {
                PathMoveHandler.SkipPathMovement();
            }
            if (gts != null && !LUA.LuaExecutionList.DemandOverride() && !PathMoveHandler.bIsBusy && !bTest && BattleGUI.TurnEffectsList.Find(te => te.bMustShow) == null)
            {
                if (bPlayerTurnEnemyOverriden)
                {
                    gts = currentEnemy;
                }

                if (GameProcessor.cameraFollowTarget != gts.character)
                {
                    GameProcessor.cameraFollowTarget = gts.character;
                }

                bTest = true;
                //randomEnemy = GamePlayUtility.Randomize(0, CombatProcessor.heroCharacters.Count - 1);
                selectedCharTurn = null;
                currentEnemy     = gts;
                AIUtility.AIPreCalculate(gts.returnCompleteArea(), gts);
                //AIUtility.Report(AIBehaviour.ProcessBehaviour(currentEnemy.character,AIUtility.possibleAITargets));
                BaseCharacter target = null;
                var           temp   = AIBehaviour.ProcessBehaviour(currentEnemy.character, AIUtility.possibleAITargets);
                if (temp.Count != 0)
                {
                    target = AIUtility.SelectTargetBasedOnBehaviour(temp);
                }

                var playableMap = GameProcessor.loadedMap.possibleTilesGameZoneForEnemy(CombatProcessor.zoneTiles, currentEnemy.character);

                var beep = new KeyValuePair <List <List <BasicTile> >, List <BasicAbility> >();
                if (target != null)
                {
                    // var beep = AIUtility.returnTilesToAttackFrom(CombatProcessor.zoneTiles,gts.character,target);
                    beep = AIUtility.returnTilesToAttackFrom(gts.returnCompleteArea(), playableMap, gts.character, target);

                    while (beep.Key.Count == 0 && beep.Value.Count == 0 && AIUtility.possibleAITargets.Count - 1 > 0)
                    {
                        AIUtility.possibleAITargets.Remove(target);
                        target = AIUtility.SelectTargetBasedOnBehaviour(AIBehaviour.ProcessBehaviour(currentEnemy.character, AIUtility.possibleAITargets));
                        beep   = AIUtility.returnTilesToAttackFrom(playableMap, playableMap, gts.character, target);
                    }
                }

                if (target != null && beep.Key.Count == 0 && beep.Value.Count == 0)
                {
                    target = null;
                }

                gts.ReGenerateTurn(playableMap);

                List <Node> allPossibleNodes;
                if (target != null)
                {
                    //allPossibleNodes = PathFinder.NewPathSearch(gts.character.position, target.position + new Vector2(64, 0), playableMap);
                    var enemyFavor = AIUtility.returnFavoredAttackAndPosition(beep, gts.character, target);
                    if (enemyFavor.Key != null)
                    {
                        allPossibleNodes = PathFinder.NewPathSearch(gts.character.position, enemyFavor.Key.mapPosition.Location.ToVector2(), playableMap);
                    }
                    else
                    {
                        allPossibleNodes = null;
                    }
                    AITarget = target;
                    AIbtba   = enemyFavor;
                }
                else
                {
                    List <int>   amountOfCharsForEachGroup = new List <int>();
                    List <float> percentagesForEachGroup   = new List <float>();
                    int          totalChars = 0;
                    foreach (var item in gts.parentTS.targetGroups)
                    {
                        int tempCount = item.charactersInGroup.FindAll(c => c.IsAlive()).Count;
                        totalChars += tempCount;
                        amountOfCharsForEachGroup.Add(tempCount);
                    }

                    foreach (var item in amountOfCharsForEachGroup)
                    {
                        percentagesForEachGroup.Add(((float)item / (float)totalChars) * 100);
                    }

                    TurnSet targetGroup = null;
                    int     tempIndex   = 0;
                    while (targetGroup == null)
                    {
                        int randomNumber = GamePlayUtility.Randomize(0, 100);
                        if (percentagesForEachGroup[tempIndex] >= randomNumber)
                        {
                            targetGroup = targetGroups[tempIndex];
                        }
                        tempIndex++;
                        if (tempIndex > percentagesForEachGroup.Count)
                        {
                            targetGroup = targetGroups[0];
                        }
                    }

                    BaseCharacter randomCharacter = targetGroup.charactersInGroup.FindAll(c => c.IsAlive())[GamePlayUtility.Randomize(0, targetGroup.charactersInGroup.FindAll(c => c.IsAlive()).Count)];

                    allPossibleNodes = PathFinder.NewPathSearch(gts.character.position, randomCharacter.position + new Vector2(64, 0), playableMap);
                }
                if (allPossibleNodes != null)
                {
                    CombatProcessor.what = new List <Node>(allPossibleNodes);
                    var NodesWithinRange = MapListUtility.findEqualNodesToTileList(allPossibleNodes, gts.returnCompleteArea());
                    PathMoveHandler.Start(gts.character, NodesWithinRange);
                }

                //FinalizeEnemyRound();
            }

            if (gts != null && !PathMoveHandler.bIsBusy && bTest && !GameProcessor.bStartCombatZoom)
            {
                //THIS IS THE VERY LAST LINE BEFORE AN ENEMY HAS IT'S TURN COMPLETED
                if (!AIbtba.Equals(default(KeyValuePair <BasicTile, BasicAbility>)))
                {
                    if ((AIbtba.Key == null || AIbtba.Key.mapPosition.Location.ToVector2() == gts.character.position) && AIbtba.Value.abilityCanHitTargetInRange(gts.character, AITarget) && AIbtba.Value.IsAbilityAvailable(gts.character.trueSTATChart()))
                    {
                        FaceCharacterInCorrectDirection(gts.character, AITarget);

                        GameProcessor.StartBattleSoon(gts.character, AITarget, gts.character.AbilityList().IndexOf(AIbtba.Value));
                        //GameProcessor.StartBattleSoon(gts.character, AITarget, gts.character.AbilityList().IndexOf(gts.character.AbilityList().Find(ba => ba.abilityName.Equals(AIbtba.Value.abilityName))));
                    }
                    else
                    {
                        if (!currentEnemy.character.attackedAsAI)
                        {
                            LastDitchEffortAttack();
                        }
                        else
                        {
                            FinalizeEnemyRound();
                        }
                    }
                }
                else
                {
                    if (!currentEnemy.character.attackedAsAI)
                    {
                        LastDitchEffortAttack();
                    }
                    else
                    {
                        FinalizeEnemyRound();
                    }
                }
                //
            }
            else if (gts == null)
            {
                if (bPlayerTurnEnemyOverriden)
                {
                    bPlayerTurnEnemyOverriden = false;
                }
            }
        }
コード例 #22
0
        static public void DrawWithEffects(SpriteBatch sb, RenderTarget2D r2d)
        {
            if (lightTex == null)
            {
                //lightTex = Game1.contentManager.Load<Texture2D>("light");
            }

            sb.End();
            sb.GraphicsDevice.SetRenderTarget(null);
            sb.GraphicsDevice.SetRenderTarget(trueLightMask);
            sb.GraphicsDevice.Clear(Color.TransparentBlack);

            sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, GameProcessor.CameraScaleMatrix);
            foreach (var item in GameProcessor.loadedMap.activeLights.FindAll(l => l.bIsLightOn))
            {
                if (item.bIsLightOn)
                {
                    Color c = item.lightColor;
                    item.lightMask.DrawLight(sb, item, item.spriteGameSize.Center.ToVector2() - (new Vector2(item.lightMask.animationFrames[0].Width / 2, item.lightMask.animationFrames[0].Height / 2)) * item.lightScale, item.lightScale, c);
                }
            }
            sb.End();



            sb.GraphicsDevice.SetRenderTarget(null);
            sb.GraphicsDevice.SetRenderTarget(lightMask);
            if (GameProcessor.bIsOverWorldOutsideGame)
            {
                sb.GraphicsDevice.Clear(worldColor * worldBrightnessLM);
            }
            else if (true)
            {
                sb.GraphicsDevice.Clear(Color.White);
            }


            sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);

            if (ThunderEffect.IsShowing())
            {
                var c = ThunderEffect.GetColor();
                sb.Draw(Game1.WhiteTex, new Rectangle(0, 0, 1366, 768), c * .95f);
            }

            sb.End();



            sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, GameProcessor.CameraScaleMatrix);
            foreach (var item in GameProcessor.loadedMap.activeLights)
            {
                // sb.Draw(lightTex, item.spriteGameSize.Center.ToVector2() - (item.spriteGameSize.Center.ToVector2() - item.spriteGameSize.Location.ToVector2()) * scale, lightTex.Bounds, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0);
                // item.Draw(sb);
                // item.lightColor = Color.White;
                if (item.bIsLightOn)
                {
                    item.lightMask.DrawLight(sb, item, item.spriteGameSize.Center.ToVector2() - (new Vector2(item.lightMask.animationFrames[0].Width / 2, item.lightMask.animationFrames[0].Height / 2)) * item.lightScale, item.lightScale, item.lightColor);
                }
            }
            sb.End();



            sb.End();



            sb.GraphicsDevice.SetRenderTarget(Game1.gameRender);

            sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, SceneUtility.transform);
            //sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, SceneUtility.transform);
            lightEffect.Parameters["lightMask"].SetValue(lightMask);
            //  lightEffect.Parameters["truelightMask"].SetValue(trueLightMask);
            //  lightEffect.Parameters["heightMask"].SetValue(GameProcessor.loadedMap.GetHeightMask());
            lightEffect.Parameters["mod"].SetValue((float)(1.0f - worldBrightnessLM));
            //      lightEffect.Parameters["mod2"].SetValue((float)(1f));
            //    lightEffect.Parameters["brightness"].SetValue((float)(worldBrightnessLM));
            //lightEffect.CurrentTechnique.Passes[0].Apply();
            lightEffect.CurrentTechnique.Passes[0].Apply();
            Rectangle renderBounds = new Rectangle(r2d.Bounds.X, r2d.Bounds.Y + ZoomHorizontalModifier, r2d.Bounds.Width, r2d.Bounds.Height - 2 * ZoomHorizontalModifier);

            //  sb.Draw(r2d, renderBounds, renderBounds, Color.White);
            //   sb.Draw(GameProcessor.objectRender, renderBounds, renderBounds, Color.Red);

            switch (currentEffect)
            {
            case Effects.None:

                renderBounds = new Rectangle(r2d.Bounds.X, r2d.Bounds.Y + ZoomHorizontalModifier, r2d.Bounds.Width, r2d.Bounds.Height - 2 * ZoomHorizontalModifier);
                if (currentTransform == Transform.None)
                {
                    sb.Draw(r2d, renderBounds, renderBounds, Color.White);
                }
                else if (currentTransform == Transform.Zoom)
                {
                    sb.Draw(r2d, -adjustZoomPosRender, renderBounds, Color.White, 0f, Vector2.Zero, zoomTo, SpriteEffects.None, 0);
                }

                break;

            case Effects.Conversation:
                sb.Draw(r2d, renderBounds, renderBounds, Color.White);
                break;

            case Effects.RegionName:
                sb.Draw(r2d, renderBounds, renderBounds, Color.White);
                break;

            case Effects.Shake:
                renderBounds.X += GamePlayUtility.Randomize(-35, 35);
                renderBounds.Y += GamePlayUtility.Randomize(-35, 35);

                sb.Draw(r2d, renderBounds, new Rectangle(r2d.Bounds.X, r2d.Bounds.Y + ZoomHorizontalModifier, r2d.Bounds.Width, r2d.Bounds.Height - 2 * ZoomHorizontalModifier), Color.White);
                break;

            default:
                break;
            }
            //sb.Draw(GameProcessor.loadedMap.GetHeightMask(), renderBounds, Color.White);
            sb.End();
        }
コード例 #23
0
        internal static KeyValuePair <BasicTile, BasicAbility> returnFavoredAttackAndPosition(KeyValuePair <List <List <BasicTile> >, List <BasicAbility> > llbtlba, BaseCharacter caster, BaseCharacter target)
        {
            List <BasicAbility> listOfNonDefaultAbilities = llbtlba.Value.FindAll(ba => !ba.abilityName.Equals(caster.CCC.AIDefaultAttack.abilityName) && ba.IsAbilityAvailable(caster.trueSTATChart()));
            BasicAbility        randomNonDefaultAbility   = new BasicAbility();
            BasicAbility        finalAbility = null;


            if (listOfNonDefaultAbilities.Count != 0)
            {
                randomNonDefaultAbility = listOfNonDefaultAbilities[GamePlayUtility.Randomize(0, listOfNonDefaultAbilities.Count)];
                int randomChance = GamePlayUtility.Randomize(0, 101);
                if (randomChance <= randomNonDefaultAbility.castChance)
                {
                    finalAbility = randomNonDefaultAbility;
                }
            }

            if (finalAbility == default(BasicAbility) && llbtlba.Value.Find(ba => ba.abilityIdentifier == caster.CCC.AIDefaultAttack.abilityIdentifier) != default(BasicAbility))
            {
                finalAbility = caster.CCC.AIDefaultAttack;
            }
            else
            {
                finalAbility = listOfNonDefaultAbilities[GamePlayUtility.Randomize(0, listOfNonDefaultAbilities.Count - 1)];
            }

            Console.WriteLine(llbtlba.Value.IndexOf(llbtlba.Value.Find(ba => ba.abilityName.Equals(finalAbility.abilityName))));

            if (llbtlba.Value.Count == 0 && llbtlba.Key.Count != 0)
            {
                while (llbtlba.Value.Count != llbtlba.Key.Count)
                {
                    llbtlba.Value.Add(finalAbility);
                }
            }

            //if(!finalAbility.abilityName.Equals(llbtlba.Value[0].abilityName, StringComparison.OrdinalIgnoreCase))
            //{
            //    finalAbility = llbtlba.Value[0];
            //}

            List <BasicTile> AbilityLocationList = llbtlba.Key[llbtlba.Value.IndexOf(llbtlba.Value.Find(ba => ba.abilityIdentifier == finalAbility.abilityIdentifier))];


            if (AbilityLocationList.Find(bt => bt.mapPosition.Location.ToVector2() == caster.position) != null)
            {
                //    AbilityLocationList.Remove(AbilityLocationList.Find(bt => bt.mapPosition.Location.ToVector2() == caster.position));
            }
            BasicTile randomDestinationTile;

            if (AbilityLocationList.Count != 0)
            {
                randomDestinationTile = AbilityLocationList[GamePlayUtility.Randomize(0, AbilityLocationList.Count)];
            }
            else
            {
                randomDestinationTile = GameProcessor.loadedMap.possibleTiles(CombatProcessor.zone.returnBoundingZone()).Find(t => t.mapPosition == caster.spriteGameSize);
            }

            return(new KeyValuePair <BasicTile, BasicAbility>(randomDestinationTile, finalAbility));
        }
コード例 #24
0
        public static void AIPreCalculate(List <BasicTile> moveRadius, CharacterTurn ct)
        {
            BaseCharacter            caster = ct.character;
            List <List <BasicTile> > abilityRangesAttack        = new List <List <BasicTile> >();
            List <List <BasicTile> > abilityRangesSupport       = new List <List <BasicTile> >();
            List <BaseCharacter>     possibleTargetCharsAttack  = new List <BaseCharacter>();
            List <BaseCharacter>     possibleTargetCharsSupport = new List <BaseCharacter>();

            List <BaseCharacter> possibleAITargetsAttack  = new List <BaseCharacter>();
            List <BaseCharacter> possibleAITargetsSupport = new List <BaseCharacter>();

            possibleAITargets.Clear();

            List <BasicAbility> attackAbilities  = caster.AbilityList().FindAll(abi => abi.abilityType == (int)BasicAbility.ABILITY_TYPE.ATTACK);
            List <BasicAbility> supportAbilities = caster.AbilityList().FindAll(abi => abi.abilityType == (int)BasicAbility.ABILITY_TYPE.SUPPORT);
            bool bCharHasSupportAbis             = supportAbilities.Count > 0;

            #region supportCheck
            if (bCharHasSupportAbis)
            {
                var listOfCharactersTemp = ct.parentTS.charactersInGroup;

                foreach (var character in listOfCharactersTemp)
                {
                    if (character.bIsAlive)
                    {
                        possibleTargetCharsSupport.Add(character);
                    }
                }

                foreach (var ability in supportAbilities)
                {
                    foreach (var character in possibleTargetCharsSupport)
                    {
                        if (character.NeedsHealing(3))
                        {
                            abilityRangesSupport.Add(MapListUtility.returnValidMapRadius(ability.abilityMinRange, ability.abilityMaxRange, CombatProcessor.zoneTiles, (character.position / 64).ToPoint().ToVector2() * 64));
                            Vector2 positionGridCaster = new Vector2((int)(caster.position.X / 64), (int)(caster.position.Y / 64));
                            var     test = abilityRangesSupport[abilityRangesSupport.Count - 1].Find(t => moveRadius.Contains(t) || (t.positionGrid.X == positionGridCaster.X && t.positionGrid.Y == positionGridCaster.Y));
                            if (test != null)
                            {
                                if (!possibleAITargetsSupport.Contains(character))
                                {
                                    possibleAITargetsSupport.Add(character);
                                }
                            }
                        }
                    }
                }
            }


            #endregion

            var listOfCharacters = ct.parentTS.targetGroups[GamePlayUtility.Randomize(0, ct.parentTS.targetGroups.Count - 1)].charactersInGroup;

            if (attackAbilities.Count != 0)
            {
                foreach (var character in listOfCharacters)
                {
                    if (character.bIsAlive)
                    {
                        possibleTargetCharsAttack.Add(character);
                    }
                }
            }

            if (possibleAITargetsSupport.Count == 0 && attackAbilities.Count != 0)
            {
                bCharHasSupportAbis = false; //If nothing is in need of healing, try prioiritize attacking instead.
            }


            foreach (var ability in attackAbilities)
            {
                if (ability.IsAbilityAvailable(caster.trueSTATChart()))
                {
                    if (ability.abilityFightStyle == (int)BasicAbility.ABILITY_CAST_TYPE.MELEE)
                    {
                        foreach (var character in possibleTargetCharsAttack)
                        {
                            abilityRangesAttack.Add(MapListUtility.returnValidMapRadius(ability.abilityMinRange, ability.abilityMaxRange, CombatProcessor.zoneTiles, (character.position / 64).ToPoint().ToVector2() * 64));
                            Vector2 positionGridCaster = new Vector2((int)(caster.position.X / 64), (int)(caster.position.Y / 64));
                            var     test = abilityRangesAttack[abilityRangesAttack.Count - 1].Find(t => moveRadius.Contains(t) || (t.positionGrid.X == positionGridCaster.X && t.positionGrid.Y == positionGridCaster.Y));
                            if (test != null)
                            {
                                if (!possibleAITargetsAttack.Contains(character))
                                {
                                    possibleAITargetsAttack.Add(character);
                                }
                            }
                        }
                    }
                    else if (ability.abilityFightStyle == (int)BasicAbility.ABILITY_CAST_TYPE.RANGED || ability.abilityFightStyle == (int)BasicAbility.ABILITY_CAST_TYPE.MAGIC)
                    {
                        abilityRangesAttack.Add(MapListUtility.returnValidMapRadius(ability.abilityMinRange, ability.abilityMaxRange, CombatProcessor.zoneTiles, (caster.position / 64).ToPoint().ToVector2() * 64));

                        foreach (var item in possibleTargetCharsAttack)
                        {
                            if (ability.abilityCanHitTargetInRange(caster, item))
                            {
                                if (!possibleAITargetsAttack.Contains(item))
                                {
                                    possibleAITargetsAttack.Add(item);
                                }
                            }
                        }
                    }
                    //else if (ability.abilityFightStyle == (int)BasicAbility.ABILITY_CAST_TYPE.RANGED)
                    //{
                    //    abilityRanges.Add(MapListUtility.returnValidMapRadius(ability.abilityMinRange, ability.abilityMaxRange, CombatProcessor.zoneTiles, (caster.position / 64).ToPoint().ToVector2() * 64));

                    //    foreach (var item in heroCharactersStillAlive)
                    //    {
                    //        if (ability.abilityCanHitTargetInRange(caster, item))
                    //        {
                    //            if (!possibleAITargets.Contains(item))
                    //            {
                    //                possibleAITargets.Add(item);
                    //            }
                    //        }
                    //    }
                    //}
                }
            }

            if (!bCharHasSupportAbis)
            {
                possibleAITargets = new List <BaseCharacter>(possibleAITargetsAttack);
            }
            else
            {
                bool  bShouldSupport        = false;
                float percentageSupportAbis = (float)((float)supportAbilities.Count / (float)caster.AbilityList().Count);
                float percentageAttackAbis  = 1 - percentageSupportAbis;
                percentageSupportAbis *= 100f;
                percentageAttackAbis  *= 100f;
                int amountOfEnemies      = possibleAITargetsAttack.Count();
                int amountOfAlliesInNeed = possibleAITargetsSupport.Count();
                if (amountOfAlliesInNeed > amountOfEnemies)
                {
                    int percent = GamePlayUtility.Randomize(30, (int)(percentageSupportAbis + 20));
                    if (percent > GamePlayUtility.Randomize(40, 70))
                    {
                        bShouldSupport = true;
                    }
                }

                if (bShouldSupport)
                {
                    possibleAITargets = new List <BaseCharacter>(possibleAITargetsSupport);
                    bDoSupport        = true;
                }
                else if (possibleTargetCharsAttack.Count != 0)
                {
                    possibleAITargets = new List <BaseCharacter>(possibleAITargetsAttack);
                    bDoSupport        = false;
                }
            }
        }
コード例 #25
0
        private SpellMissile CalculateRandomSimpleShot(Shape shooter, Vector2 target, List <Spell> extraSpells)
        {
            //Random rand2 = new Random();
            int temp = GamePlayUtility.Randomize(0, extraSpells.Count);

            float spellAngleNR = (float)(spellAngle / Math.PI * 180);
            float angle        = 3.6f * 4;
            int   divider      = 15;

            SpellMissile tempMissile = new SpellMissile(extraSpells[temp],
                                                        extraSpells[temp].spellTextureSpriteSheet,
                                                        1,
                                                        shooter.position,
                                                        true,
                                                        default(Vector2),
                                                        extraSpells[temp].spellName,
                                                        extraSpells[temp].spellHitBox);


            float maxAngle = 0f;
            float minAngle = 0f;

            float deltaY      = target.Y - tempMissile.centerPoint.Y;
            float deltaX      = target.X - tempMissile.centerPoint.X;
            float angleVector = (float)(Math.Atan2(deltaY, deltaX) + Math.PI / 2);


            maxAngle = angleVector + (float)(Math.PI / 3);
            maxAngle = angleVector - (float)(Math.PI / 3);

            spellAngleNR = (float)(angleVector * 180 / Math.PI);
            if (spellAngleNR < 0)
            {
                spellAngleNR += 360;
            }

            if (spellAngleNR > 360 - 45 && spellAngleNR < 45)
            {
                tempMissile.Rotate(0);
            }
            else if (spellAngleNR < 360 - 45 && spellAngleNR > 360 - 45 - 90)
            {
                tempMissile.Rotate(90);
            }
            else if (spellAngleNR < 360 - 45 - 90 && spellAngleNR > 45 + 90)
            {
                tempMissile.Rotate(180);
            }
            else if (spellAngleNR > 45 && spellAngleNR < 45 + 90)
            {
                tempMissile.Rotate(270);
            }

            //Console.Out.WriteLine(angleVector*180/Math.PI);
            tempMissile.speed         = 3;
            tempMissile.bStopAtTarget = false;
            // shapes[shapes.Count - 1].SetVelocity(new Vector2((float)Math.Sin(spellAngle), (float)Math.Cos(spellAngle)) * speed);
            tempMissile.SetVelocity(angleVector);

            return(tempMissile);
        }