Inheritance: MonoBehaviour
Exemplo n.º 1
0
        public ActionResult Index(int attackerId, int targetId)
        {
            Player attacker = Player.Find(attackerId);
            Player target   = Player.Find(targetId);

            Dictionary <string, object> model = new Dictionary <string, object>();

            model.Add("user", attacker);
            model.Add("enemy", target);

            List <string> battleMsg = new List <string>();

            model.Add("msg", battleMsg);

            battleMsg.Add(target.GetName() + ": " + BattleText.Find(target.GetFlavorId()).GetStart());

            if (target.GetAgility() > attacker.GetAgility())
            {
                battleMsg.Add(Player.RandomAttack(target, attacker));
            }

            if (attacker.GetHPRemaining() <= 0)
            {
                Player.DeleteAll();
                BattleText.DeleteAll();
                return(RedirectToAction("Index", "Home"));;
            }
            return(View("Index", model));
        }
Exemplo n.º 2
0
        public static int GetInputValueHandlingExceptions(int factor, int minValue, int maxValue)
        {
            int selectedValue = 0;

            try
            {
                selectedValue = Int16.Parse(StoryText.GetInputValue());
            }
            catch (FormatException ex)
            {
                BattleText.SelectValueHandlingExceptionsText();
                selectedValue = GetInputValueHandlingExceptions(factor, minValue, maxValue);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            if (selectedValue > maxValue)
            {
                StoryText.EnterAValueFromTheMaximumToTheMinimumText(minValue, maxValue);
                selectedValue = GetInputValueHandlingExceptions(factor, minValue, maxValue);
            }
            if (selectedValue < minValue)
            {
                StoryText.EnterAValueFromTheMaximumToTheMinimumText(minValue, maxValue);
                selectedValue = GetInputValueHandlingExceptions(factor, minValue, maxValue);
            }

            return(selectedValue - factor);
        }
Exemplo n.º 3
0
    public void ShowDamageText(CharData character, int value, TextType type)
    {
        BattleText currentText = GetDamageText();

        if (currentText == null)
        {
            return;
        }

        currentText.transform.position  = character.charView.transform.position;
        currentText.transform.position += new Vector3(Random.Range(-floatX, floatX), Random.Range(-floatY, floatY));
        currentText.SetText(value.ToString());
        if (type == TextType.Damage)
        {
            currentText.SetColor(damageColor1, damageColor2);
        }
        else if (type == TextType.Heal)
        {
            currentText.SetColor(healColor1, healColor2);
        }
        else if (type == TextType.Armor)
        {
            currentText.SetColor(armorColor1, armorColor2);
        }

        currentText.OpenText(closeTime);
        currentText.transform.SetAsLastSibling();
        currentText.transform.DOPunchScale(new Vector3(1.2f, 1.2f, 1), 0.5f, 5, 1.3f);
    }
Exemplo n.º 4
0
 public void AddBattleTextSprite(BattleText bt)
 {
     GameObject tmp = GameObject.CreatePrimitive(PrimitiveType.Plane);
     tmp.name = "_BattleTextSprite";
     BattleTextSprite sprite = (BattleTextSprite)tmp.AddComponent("BattleTextSprite");
     sprite.battleText = bt;
     this.AddSprite(sprite);
 }
Exemplo n.º 5
0
        private void Attack(Hero atacker, Hero enemy)
        {
            Weapon weapon = atacker.Inventory[0] as Weapon;

            if (weapon != null && atacker.Durability > 0)
            {
                if (enemy.Durability < weapon.Hardness)
                {
                    enemy.Durability -= weapon.Damage;

                    BattleText.BattleStats(weapon, enemy);

                    if (enemy.Durability == 0)
                    {
                        enemy.Life -= weapon.Damage;
                    }

                    if (enemy.Life <= 0)
                    {
                        BattleText.OpponentDefeated();
                        enemy.IsLife = false;
                    }

                    atacker.HeroDurabilityDownUp(durabilityDown, 0);

                    BattleText.BattleDurabilityDown(atacker);
                }
                else
                {
                    BattleText.TheWeaponDoesNotHurt();

                    weapon.Hardness--;

                    BattleText.StateOfArms(weapon);

                    if (weapon.Hardness <= 0)
                    {
                        heroes[j].Inventory[0] = null;
                        BattleText.WeaponDestroyed(weapon);
                    }
                }
            }
            else
            {
                if (atacker.Durability == 0)
                {
                    BattleText.DurabilityDownZero(atacker);
                }
                if (weapon == null)
                {
                    BattleText.NoWeapon();
                }
            }
            if (!enemy.IsLife)
            {
                enemies.Remove(enemy);
            }
        }
Exemplo n.º 6
0
    public IEnumerator Do()
    {
        //暗転を解除
        yield return(StartCoroutine(SceneFader.FadeSceneIn()));

        //遭遇メッセージを表示
        yield return(StartCoroutine(BattleMessage.GetWindow().ShowAuto(BattleText.Get("BattleStart"))));

        yield break;
    }
Exemplo n.º 7
0
 void Start()
 {
     this.enemy           = GetComponent <EnemyParams>();
     this.player          = GetComponent <PlayerParams>();
     this.enemyCurrentHP  = this.enemy.hp;
     this.playerCurrentHP = this.player.hp;
     this.enemyObject     = GameObject.Find("Enemy");
     this.enemyObject.GetComponent <SpriteRenderer>().sprite = this.enemy.CharacterSprite;
     this.battlelog           = GameObject.Find("BattleLog");
     this.battleText          = GetComponent <BattleText>();
     this.activatedActionList = new bool[this.enemy.routineList.Length];
     this.SetBattleLog(this.battleText.BattleStart);
 }
Exemplo n.º 8
0
    public void SpawnText()
    {
        UpdateLog("SpawnText");

        GameObject newObject = GameObject.Instantiate(prefab);

        newObject.transform.position = Vector3.zero;

        BattleText text = newObject.GetComponent <BattleText>();

        text.text = "10000";
        text.Play(() => {
            AppendLog("End of Animation");
        });
    }
Exemplo n.º 9
0
        public ActionResult UpdateStat(int id, int statId)
        {
            Player foundPlayer = Player.Find(id);

            if (statId == 0)
            {
                foundPlayer.SetLuck(foundPlayer.GetLuck() + 1);
            }
            else if (statId == 1)
            {
                foundPlayer.SetAgility(foundPlayer.GetAgility() + 1);
            }
            else if (statId == 2)
            {
                foundPlayer.SetIntelligence(foundPlayer.GetIntelligence() + 1);
            }
            else if (statId == 3)
            {
                foundPlayer.SetStrength(foundPlayer.GetStrength() + 1);
            }
            foundPlayer.Update();

            if (Player.GetEnemies().Count == 0)
            {
                Player michaelJordan = new Player("Michael Jordan", 50, 50, 8, 8, 8, 8);
                michaelJordan.Save();

                BattleText t1 = new BattleText(
                    "I see you have destroyed my goblins. However you will never defeat me!!!!",
                    "Your skull will make a superb addition to my collection",
                    "Man I really snapped. You did good buddy!!"
                    );
                t1.Save();

                michaelJordan.SetFlavorId(t1.GetId());

                Dictionary <string, object> mjmodel = new Dictionary <string, object>();
                mjmodel.Add("user", foundPlayer);
                mjmodel.Add("enemy", michaelJordan);
                return(View("Final", mjmodel));
            }

            return(RedirectToAction("Index", "Court"));
        }
Exemplo n.º 10
0
        public List <Hero> Initialize()
        {
            BattleText.BattleStart();
            Console.Clear();

            do
            {
                durabilityDown++;

                j = randomAttack.Next(0, heroes.Count);

                Weapon weapon = heroes[j].Inventory[0] as Weapon;

                StoryText.SetColor(ConsoleColor.Green);

                if (weapon.Hardness <= 0)
                {
                    Console.WriteLine();
                    StoryText.HeroColorText(heroes[j]);
                    BattleText.InformationWeaponDestroyed();
                }
                else
                {
                    BattleText.PresentationOfAttacker(heroes[j]);

                    if (j == 0)
                    {
                        BattleText.PresentationEnemies(enemies);
                    }
                    else
                    {
                        BattleText.CompanionAtackEnemyPresentation(enemies);
                    }

                    if (j == 1)
                    {
                        selectedEnemy = randomAttack.Next(0, enemies.Count);

                        BattleText.HeroRandomAttack(heroes, enemies, j, selectedEnemy);
                    }
                    else
                    {
                        Console.SetCursorPosition(0, 25);
                        BattleText.SelectEnemyNumber();
                        selectedEnemy = GameCore.GetInputValueHandlingExceptions(1, 0, 2);
                    }

                    Attack(heroes[j], enemies[selectedEnemy]);

                    StoryText.ResetColor();

                    if (enemies.Count > 0)
                    {
                        i = randomAttack.Next(0, enemies.Count);

                        var heroesNumber = randomAttack.Next(0, heroes.Count);

                        BattleText.RandomEnemyAttack(heroes, enemies, j, i);

                        Console.ForegroundColor = ConsoleColor.Red;

                        Weapon weaponEn = enemies[i].Inventory[0] as Weapon;

                        BattleText.PresentationOfAttacker(enemies[i]);

                        Attack(enemies[i], heroes[heroesNumber]);

                        //StoryText.SelectWayDisplayDelay(4);
                        Console.Clear();

                        if (!heroes[heroesNumber].IsLife)
                        {
                            if (heroes[heroesNumber] == heroes[0])
                            {
                                mainHeroLive = false;
                            }
                        }
                        Console.ResetColor();
                    }
                }
            } while (enemies.Count > 0 && mainHeroLive);

            return(heroes);
        }
Exemplo n.º 11
0
        public ActionResult Attack(int attackerId, int targetId, int attackMove)
        {
            Player attacker = Player.Find(attackerId);
            Player target   = Player.Find(targetId);

            Dictionary <string, object> model = new Dictionary <string, object>();

            model.Add("user", attacker);
            model.Add("enemy", target);

            List <string> battleMsg = new List <string>();

            model.Add("msg", battleMsg);

            int halfHealth    = target.GetHPTotal() / 2;
            int currentHealth = target.GetHPRemaining();

            string attackMsg = "";

            if (attackMove == 0)
            {
                attackMsg = Player.AttackShoot(attacker, target);
            }
            else if (attackMove == 1)
            {
                attackMsg = Player.AttackTimeOut(attacker);
            }
            else if (attackMove == 2)
            {
                attackMsg = Player.AttackDunk(attacker, target);
            }
            else if (attackMove == 3)
            {
                attackMsg = Player.AttackZoneDefense(attacker, target);
            }

            battleMsg.Add(attackMsg);

            if (target.GetHPRemaining() <= 0)
            {
                if (Player.GetEnemies().Count == 1 && target.GetName() == "Michael Jordan")
                {
                    target.Delete();
                    return(View("Win"));
                }

                battleMsg.Add(target.GetName() + ": " + BattleText.Find(target.GetFlavorId()).GetEnd());
                target.Delete();
                return(View("EndBattle", model));
            }
            else if (currentHealth > halfHealth && target.GetHPRemaining() <= halfHealth)
            {
                battleMsg.Add(target.GetName() + ": " + BattleText.Find(target.GetFlavorId()).GetMid());
            }

            battleMsg.Add(Player.RandomAttack(target, attacker));

            if (attacker.GetHPRemaining() <= 0)
            {
                Player.DeleteAll();
                return(View("Lose"));
            }

            return(View("Index", model));
        }
Exemplo n.º 12
0
 void Awake()
 {
     S = this;
 }
Exemplo n.º 13
0
        public ActionResult CreatePlayer()
        {
            string name = Request.Form["name"];
            int    agility;
            int    intel;
            int    strength;
            int    luck;

            if (!int.TryParse(Request.Form["agility"], out agility))
            {
                agility = 0;
            }
            if (!int.TryParse(Request.Form["intel"], out intel))
            {
                intel = 0;
            }
            if (!int.TryParse(Request.Form["strength"], out strength))
            {
                strength = 0;
            }
            if (!int.TryParse(Request.Form["luck"], out luck))
            {
                luck = 0;
            }


            if (agility == 0 && intel == 0 && strength == 0 && luck == 0)
            {
                Player newPlayer = new Player(name, 20, 20);
                newPlayer.SetAllegience(true);
                newPlayer.Save();
            }
            else
            {
                Player newPlayer = new Player(name, 20, 20, agility, intel, strength, luck);
                newPlayer.SetAllegience(true);
                newPlayer.SetX(0);
                newPlayer.SetY(6);
                newPlayer.Save();
            }
            Player enemy1 = new Player("Kayla", 20, 20);

            enemy1.SetX(6);
            enemy1.SetY(2);
            Player enemy2 = new Player("Frank", 20, 20);

            enemy2.SetX(12);
            enemy2.SetY(5);
            Player enemy3 = new Player("Cam", 20, 20);

            enemy3.SetX(18);
            enemy3.SetY(7);
            Player enemy4 = new Player("Nico", 20, 20);

            enemy4.SetX(8);
            enemy4.SetY(2);
            Player enemy5 = new Player("Johnny", 20, 20);

            enemy5.SetX(16);
            enemy5.SetY(4);

            enemy1.Save();
            enemy2.Save();
            enemy3.Save();
            enemy4.Save();
            enemy5.Save();

            BattleText t1 = new BattleText(
                "This is gonna be a SLAM DUNK!",
                "Im just gettin warmed up!",
                "Im sorry Michael. Ive let you down..."
                );

            t1.Save();

            BattleText t2 = new BattleText(
                "I dont know if I can beat you, but Ill do my best!",
                "This isnt going well...",
                "Well at least I tried."
                );

            t2.Save();

            BattleText t3 = new BattleText(
                "Check out these sweet moves!!",
                "Im a second half player...",
                "* walks away angrily *"
                );

            t3.Save();

            Random     rnd   = new Random();
            List <int> texts = BattleText.GetIds();

            enemy1.SetFlavorId(texts[rnd.Next(texts.Count)]);
            enemy2.SetFlavorId(texts[rnd.Next(texts.Count)]);
            enemy3.SetFlavorId(texts[rnd.Next(texts.Count)]);
            enemy4.SetFlavorId(texts[rnd.Next(texts.Count)]);
            enemy5.SetFlavorId(texts[rnd.Next(texts.Count)]);

            return(RedirectToAction("Index", "Court"));
        }
Exemplo n.º 14
0
 public ActionResult CreatePlayerForm()
 {
     Player.DeleteAll();
     BattleText.DeleteAll();
     return(View());
 }
Exemplo n.º 15
0
        public Hero LoadLevel3(Hero hero, Hero hero2)
        {
            int direction;

            TheBeginningOfTheLevel("3");

            StoryText.HeroCondition(hero);

            #region BodyLevel

            Level3Text.TwoExitsFromTheCave();

            Console.WriteLine();

            Level3Text.SimpleRoadSelection();

            direction = GameCore.GetInputValueHandlingExceptions(0, 1, 2);

            do
            {
                if (direction == 1)
                {
                    Console.WriteLine();

                    Level3Text.MeetingOfACompanion(hero2);

                    StoryText.SelectWayDisplayDelay(4);

                    hero.Inventory[0] = new Weapon(2, 15, 5, "Stick");

                    CreateScene.LoadScene("Level3StickScene");

                    StoryText.HeroCondition(hero2);

                    #region CreatingHeroesAndEnemies

                    List <Hero> heroes = new List <Hero>();

                    heroes.Add(hero);
                    heroes.Add(hero2);

                    List <Hero> enemy = new List <Hero>()
                    {
                        new Hero()
                        {
                            HeroID     = 3,
                            Durability = 10,
                            IsLife     = true,
                            Name       = "Ogr 1",
                            Life       = 2,
                            Inventory  = new Weapon[] { new Weapon(1, 5, 1, "Arm") }
                        },
                        new Hero()
                        {
                            HeroID     = 4,
                            Durability = 10,
                            IsLife     = true,
                            Name       = "Ogr 2",
                            Life       = 2,
                            Inventory  = new Weapon[] { new Weapon(1, 5, 1, "Arm") }
                        }
                    };

                    #endregion CreatingHeroesAndEnemies


                    Battle battle = new Battle(heroes, enemy);
                    heroes = battle.Initialize();

                    if (hero.IsLife)
                    {
                        hero.LevelEnd = true;
                        BattleText.VictoryInBattle();
                        Console.ReadKey();
                    }
                }
                else
                {
                    Level3Text.KilledByAnAnimal();
                    hero.IsLife = false;

                    StoryText.SelectWayDisplayDelay(4);
                }
            } while (hero.IsLife && !hero.LevelEnd);

            return(hero);

            #endregion BodyLevel
        }