Example #1
0
        public BattleState()
        {
            _clock = new ScaledClock(Globals.BattleSpeed);

            _allies = new Ally[3];

            if (Globals.Party[0] != null) _allies[0] = new Ally(Globals.Party[0], 550, 100, 2000);
            if (Globals.Party[1] != null) _allies[1] = new Ally(Globals.Party[1], 580, 200, 2500);
            if (Globals.Party[2] != null) _allies[2] = new Ally(Globals.Party[2], 610, 300, 2300);

            if (_allies[0] == null && _allies[1] == null && _allies[2] == null)
                throw new GamedataException("Must have at least one ally in battle.");

            int numberOfEnemies = 1;//Game.Random.Next(1, 3);
            //_enemies = new List<Enemy>(numberOfEnemies);
            //for (int i = 0; i < numberOfEnemies; i++)
            //    _enemies.Add(Enemy.GetRandomEnemy(Game.Random.Next(100, 250), Game.Random.Next(100, 300)));

            _enemies = new List<Enemy>();
            _enemies.Add(new Enemy("mothslasher"));

            _turnQueue = new Queue<Ally>();

            _abilityQueue = new Queue<AbilityState>();

            _abilityMutex = new Mutex();

            _gainedItems = new List<IItem>();
        }
 Ally spawnBattler(string name, float x, float y)
 {
     Ally battler = new Ally(name);
     battler.Sprite.LocalPriority = 0.1f;
     battler.LocalPixelPosition = new Vector2(x, y);
     this.battlers.Add(battler);
     return battler;
 }
Example #3
0
        public StealEvent(Ally source, IEnumerable<Combatant> targets)
            : base(source, true)
        {
            Enemy enemy = targets.First() as Enemy;

            if (enemy == null)
            {
                throw new ImplementationException("Cannot steal from an Ally.");
            }

            Target = enemy;
        }
Example #4
0
    //Called from the PlayerInput scripts and / or the Ally button OnClick() event
    public void SummonAlly()
    {
        //If there is no ally manager, leave
        if (allyManager == null)
        {
            return;
        }
        //Attempt to get an Ally by calling SummonAlly()
        Ally ally = allyManager.SummonAlly();

        //If SummonAlly() was able to spawn an ally...
        if (ally != null)
        {
            //...set the ally as the target of the enemies...
            EnemyTarget = ally.transform;
            //...and call UnsummonAlly() after a set delay
            Invoke("UnSummonAlly", ally.Duration);
        }
    }
    public string UseInField(Skill skill, List <Unit> unitList, Ally ally)
    {
        List <Ally> allies = gameController.AllyManager.Allies;
        Unit        toUnit = allies.Find(a => a.ID1 == gameController.AllyManager.SelectedAllyID);

        string message = "";

        if (skill.SkillName == SkillName.テレポート)
        {
            message = skill.Message1;
        }
        else
        {
            message = Use(skill, unitList, ally, toUnit);
        }

        gameController.AllyManager.UpdatePanels();

        return(message);
    }
Example #6
0
        }         //end ResolveFight(GameObject player)

        public string ResolveAlly(GameObject player, string p_GUIresult)
        {
            //Create ally
            GameObject m_ally = Instantiate(PrefabReference.prefabCharacter,
                                            m_player.transform.position, new Quaternion()) as GameObject;

            // Remove the sprite renderer component. This makes the ally not shown on the map.
            Destroy(m_ally.GetComponent <SpriteRenderer>());

            //Generate script
            Character m_allyScript = m_ally.GetComponent <Character>();

            //Set max weight
            m_allyScript.MaxWeight = m_die.Roll(1, 20) * 6;

            //Player accepts ally
            if (p_GUIresult == "YES")
            {
                //Add to ally list
                Ally m_playerAllyScript = m_player.GetComponent <Ally>();
                m_playerAllyScript.AddAlly(m_ally);

                //Return accepted
                m_GUIResult = "Ally was added.";
                return("Ally Was Added.");
            }

            //Player declines ally
            else if (p_GUIresult == "NO")
            {
                //Destroy newAlly
                Destroy(m_ally);

                //Return decline
                m_GUIResult = "Ally was declined.";
                return("No ally was added.");
            }             //end else if

            //Otherwise wait for answer
            return("No choice was made.");
        }         //end ResolveAlly(GameObject player, string p_GUIresult)
Example #7
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         Player player = collision.gameObject.GetComponent <Player>();
         if (player != null)
         {
             player.setCanMove(false);
             setCanMove(false);
         }
     }
     else if (collision.gameObject.tag == "Ally")
     {
         Ally ally = collision.gameObject.GetComponent <Ally>();
         if (ally != null)
         {
             ally.setCanMove(false);
             setCanMove(false);
         }
     }
 }
Example #8
0
    public void FillMenu(Ally unit)
    {
        UnitCommand[] commands = unit.commands;
        commandMenuTransform.gameObject.SetActive(true);
        int childrenToDestroy = commandMenuTransform.childCount;

        for (int i = 0; i < childrenToDestroy; i++)
        {
            Destroy(commandMenuTransform.GetChild(i).gameObject);
        }
        for (int i = 0; i < commands.Length; i++)
        {
            RectTransform   newCommand  = Instantiate(commandPrefab, commandMenuTransform) as RectTransform;
            TextMeshProUGUI commandText = newCommand.GetComponentInChildren <TextMeshProUGUI>();
            commandText.text     = commands[i].action.GetActionName();
            commandText.fontSize = fontSize;
        }
        selectedAction = 0;
        CalculateCursorPosition();
        isMenuDrawn = true;
    }
    public void TestSwapUnits()
    {
        GameObject testContainer = new GameObject();

        testContainer.AddComponent <Ally> ();
        Ally    unit     = testContainer.GetComponent <Ally> ();
        Vector3 position = new Vector3(0.0f, 0.0f, 0.0f);

        TileData tileData1 = new TileData(TileData.TerrainTypeEnum.DESERT, true, "", 0, 0, 0, 0, position, position, "", "unit1");

        tileData1.Unit = unit;
        TileData tileData2 = new TileData(TileData.TerrainTypeEnum.DESERT, true, "", 0, 0, 0, 0, position, position, "");

        Assert.NotNull(tileData1.Unit);
        Assert.Null(tileData2.Unit);

        tileData1.SwapUnits(tileData2);

        Assert.Null(tileData1.Unit);
        Assert.NotNull(tileData2.Unit);
    }
Example #10
0
    private IEnumerator Skill()
    {
        while (true)
        {
            Ally suppTarget = this;
            if (SceneManager.Instance.allies.Count > 0)
            {
                suppTarget = SceneManager.Instance.allies[0];
            }
            if (designatedSkillTarget != null && designatedSkillTarget is Ally)
            {
                suppTarget = (Ally)designatedSkillTarget;
            }

            IncOutDamage b = new IncOutDamage(buffCoeff, buffTime, suppTarget, this);
            suppTarget.GetBuff(b);
            skillCalled = false;
            state       = State.AutoAttack;
            yield break;
        }
    }
Example #11
0
    public void Show(Ally commander, params Command[] Commands)//根据命令显示UI项
    {
        sprite_BG.enabled = true;
        point.SetActive(true);
        point.transform.localPosition = new Vector3(400, 270, 0);

        sprite_BG.height = 80 + Commands.Length * (Commands.Length == 1?0: Commands.Length == 2?30:40);
        sprite_BG.gameObject.transform.localPosition = new Vector3(590, 310, 0);

        for (var i = 0; i < Commands.Length; i++)
        {
            GameObject com = Instantiate <GameObject>(prefab_commandLabel);
            com.transform.SetParent(CommandList);
            com.transform.localScale          = Vector3.one;
            com.transform.localPosition       = new Vector3(450, 270 - (i * (50 + 10)), 0);
            com.GetComponent <UILabel>().text =
                Commands[i] == Command.Attack ? "攻击" : Commands[i] == Command.RoundOver ? "结束" : "待命";
        }
        active         = true;
        this.commander = commander;
    }
Example #12
0
        public void SwitchBodiesWith(int chosenOppId)
        {
            VerifyId(chosenOppId);
            if (IsCreatureFriendly(chosenOppId))
            {
                throw new ArgumentException(
                          "The creature with selected id is already friendly and as such is not a valid target for switching bodies with.");
            }
            // ReSharper disable once PossibleNullReferenceException
            float previousAllysHPPercent = _creatures.Find(cr => cr is Ally).CurrentHP
                                           // ReSharper disable once PossibleNullReferenceException
                                           / (float)_creatures.Find(cr => cr is Ally).MaxHP;
            float previousOppsHPPercent = _creatures[chosenOppId].CurrentHP / (float)_creatures[chosenOppId].MaxHP;
            bool  leftOldAlly = false, assumedNewShape = false;

            for (int creatureId = 0; creatureId < DisplaySettings.NumberOfOpps; creatureId++)
            {
                if (!leftOldAlly && _creatures[creatureId] is Ally)
                {
                    Opponent oldAlly = (Ally)_creatures[creatureId];
                    oldAlly.CurrentHP      = (byte)Math.Ceiling(oldAlly.MaxHP * previousOppsHPPercent);
                    _creatures[creatureId] = oldAlly;
                    leftOldAlly            = true;
                }

                if (!assumedNewShape && creatureId == chosenOppId)
                {
                    Ally newAlly = (Opponent)_creatures[creatureId];
                    newAlly.CurrentHP      = (byte)Math.Ceiling(newAlly.MaxHP * previousAllysHPPercent);
                    _creatures[creatureId] = newAlly;
                    assumedNewShape        = true;
                }

                if (assumedNewShape && leftOldAlly)
                {
                    break;
                }
            }
        }
Example #13
0
 public static int CalculateEnemyTypeDamage(int value, Skill skill, Unit fromUnit, Unit toUnit)
 {
     if (toUnit.GetType() == typeof(Enemy))
     {
         int   rate  = 100;
         Enemy enemy = toUnit as Enemy;
         Ally  ally  = fromUnit as Ally;
         foreach (EnemyType e in enemy.EnemyTypes)
         {
             if (ally.EquippedWeapon.Effectivenesses.ContainsKey(e))
             {
                 rate += ally.EquippedWeapon.Effectivenesses[e];
             }
         }
         value *= (rate / 100);
         return(value);
     }
     else
     {
         return(value);
     }
 }
Example #14
0
    public void selectCharacters()
    {
        //turn selection mode on/off
        selectionMode = !selectionMode;
        if (selectionMode)
        {
            //set cursor and button color to show the player selection mode is active
            selectButton.GetComponent <Image>().color = Color.red;
            Cursor.SetCursor(cursorTexture1, Vector2.zero, CursorMode.Auto);
            if (GameObject.Find("Mobile multiplayer"))
            {
                if (MobileMultiplayer.deployMode)
                {
                    GameObject.Find("Mobile multiplayer").GetComponent <MobileMultiplayer>().toggleDeployMode();
                }
                MobileMultiplayer.camEnabled = false;
            }
        }
        else
        {
            //show the player selection mode is not active
            selectButton.GetComponent <Image>().color = Color.white;
            Cursor.SetCursor(cursorTexture, Vector2.zero, CursorMode.Auto);

            //set target object false and deselect all units
            foreach (GameObject Ally in allies)
            {
                if (Ally != null)
                {
                    Ally.GetComponent <CharacterMultiplayer>().selected = false;
                }
            }
            target.SetActive(false);
            if (GameObject.Find("Mobile multiplayer"))
            {
                MobileMultiplayer.camEnabled = true;
            }
        }
    }
Example #15
0
    int allyPoints;             //How many points the player currently has to spend on allies

    void Awake()
    {
        //从实例化实例开始一个盟友游戏对象
        //Start by instantiating an ally game object from a prefab
        GameObject obj = (GameObject)Instantiate(allyPrefab);

        //然后将其作为该游戏对象的父对象
        //Then parent it to this game object
        obj.transform.parent = transform;
        //然后获取对其Ally脚本的引用
        //Then grab a reference to its Ally script
        ally = obj.GetComponent <Ally>();
        //最后将其禁用,以便以后使用
        //Finally disable it so it is ready to be used later
        obj.SetActive(false);
        //如果存在allyImage,请将其禁用
        //If the allyImage exists, disable it
        if (allyImage != null)
        {
            allyImage.enabled = false;
        }
    }
Example #16
0
    // Use this for initialization
    void Start()
    {
        projectiles = new List <GameObject>();
        party       = TitleManager.curFile.getParty();
        curDude     = party[0];
        for (int i = 0; i < party.Count; i++)
        {
            if (party[i].getCharacter() == character.ANNIE)
            {
                annie = party[i];
                break;
            }
        }

        // Make the bag enemy
        int[]    theStats = { 0, 0, 0, theBag.def, 0, theBag.mdef, 0 };
        Sprite[] idleBag  = new Sprite[1];
        Sprite[] hurtBag  = new Sprite[1];
        idleBag[0] = theBag.ok;
        hurtBag[0] = theBag.hurt;
        SpriteAnimation idle = new SpriteAnimation(idleBag, new int[0], 0, true);
        SpriteAnimation hurt = new SpriteAnimation(hurtBag, new int[0], 0, true);

        mrsBag = new Foe("Mrs. Bag", theStats, new List <Skill>(), new int[0],
                         new AItype[0], new Item[0], new int[0], theBag.hurtbox, 3f);
        mrsBag.setAnimations(null, idle, idle, idle, idle, hurt);

        ResetFighters();
        b3time = 0;

        // Hide menu
        textDisplay(mainOpts, false);
        textDisplay(skills, false);
        textDisplay(skillInfo, false);
        textDisplay(tips, false);
        description.enabled = false;
        answer.enabled      = false;
        menuScreen.GetComponent <SpriteRenderer>().enabled = false;
    }
Example #17
0
    private IEnumerator Skill()
    {
        while (true)
        {
            Ally tankTarget = this;
            if (SceneManager.Instance.allies.Count > 0)
            {
                tankTarget = SceneManager.Instance.allies[0];
            }
            if (designatedSkillTarget != null && designatedSkillTarget is Ally)
            {
                tankTarget = (Ally)designatedSkillTarget;
            }

            Shield shld = new Shield(shieldAmount, shieldTime, tankTarget, this);
            tankTarget.GetBuff(shld);
            tankTarget.hpbar.UpdateShield(tankTarget.GetTotalShield());
            skillCalled = false;
            state       = State.AutoAttack;
            yield break;
        }
    }
Example #18
0
        public void UseInBattle(Ally source, IEnumerable <Combatant> targets)
        {
            targets.Count();

            if (CanUseInBattle)
            {
                try
                {
                    switch (BattleUsage.Target)
                    {
                    case BattleTarget.Combatant:
                    case BattleTarget.Ally:
                    case BattleTarget.Enemy:
                        BattleUsage.Use.Call(source, targets.First());
                        break;

                    case BattleTarget.Area:
                    case BattleTarget.AreaRandom:
                    case BattleTarget.Group:
                    case BattleTarget.GroupRandom:
                    case BattleTarget.Allies:
                    case BattleTarget.AlliesRandom:
                    case BattleTarget.Enemies:
                    case BattleTarget.EnemiesRandom:
                        BattleUsage.Use.Call(source, targets.ToList());
                        break;
                    }
                }
                catch (Exception e)
                {
                    throw new ImplementationException("Error calling battle script; id = " + ID, e);
                }
            }
            else
            {
                throw new ImplementationException("Tried to use an item in battle that can't be used in battle.");
            }
        }
Example #19
0
    void OnGUI()
    {
        //check if rectangle should be visible
        if (visible)
        {
            // Find the corner of the box
            Vector2 origin;
            origin.x = Mathf.Min(mouseDownPos.x, mouseLastPos.x);

            // GUI and mouse coordinates are the opposite way around.
            origin.y = Mathf.Max(mouseDownPos.y, mouseLastPos.y);
            origin.y = Screen.height - origin.y;

            //Compute size of box
            Vector2 size = mouseDownPos - mouseLastPos;
            size.x = Mathf.Abs(size.x);
            size.y = Mathf.Abs(size.y);

            // Draw the GUI box
            Rect rect = new Rect(origin.x, origin.y, size.x, size.y);
            GUI.Box(rect, "", rectangleStyle);

            foreach (GameObject Ally in allies)
            {
                if (Ally != null)
                {
                    Vector3 pos = Camera.main.WorldToScreenPoint(Ally.transform.position);
                    pos.y = Screen.height - pos.y;
                    //foreach selectable character check its position and if it is within GUI rectangle, set selected to true
                    if (rect.Contains(pos))
                    {
                        Ally.GetComponent <CharacterMultiplayer>().selected = true;
                    }
                }
            }
        }
    }
Example #20
0
    public static IEnumerator StartHealing(Unit origin, Unit target)
    {
        bool isAlly       = origin.GetType() == typeof(Ally);
        Ally originAsAlly = null;

        UnitCommand[] commandCache = null;
        if (isAlly)
        {
            originAsAlly = origin as Ally;
            commandCache = originAsAlly.commands;
            UnitCommand stopHealingCommand = new UnitCommand(UnitActions.Stop, 0);
            originAsAlly.commands = new UnitCommand[] { stopHealingCommand };
            origin.state          = UnitStates.CannotAction;
            yield return(null);
        }
        origin.state = UnitStates.CanAction;
        for (float timer = 0; true; timer += Time.deltaTime)
        {
            if (origin.state == UnitStates.InterruptAction || target == null)
            {
                break;
            }

            if (!(timer < timeBetweenHeals))
            {
                timer = 0;
                target.OnHealthChanged(-10);
            }
            yield return(null);
        }
        if (isAlly)
        {
            originAsAlly.commands = commandCache;
            MenuManager.Instance.FillMenu(originAsAlly);
        }
        origin.state = UnitStates.CanAction;
    }
    void SpawnUnit()
    {
        bool isAnyEnemyInRange = Physics.OverlapSphere(_goldPile.transform.position, GlobalTargetBreachRadius, EnemiesLayer).Length > 0;

        if ((Squad.Count >= PopulationCap) || !isAnyEnemyInRange)
        {
            return;
        }
        GameObject ally = (GameObject)Instantiate(PikemanPrefab, _spawnPoint, this.transform.rotation);

        ally.transform.Translate(new Vector3(0, 0, 4));
        Ally allyScript = ally.GetComponent <Ally>();

        allyScript.goldPile                = GameObject.Find("GoldPile");
        allyScript.speed                   = 5;
        allyScript.EnemiesLayer            = EnemiesLayer;
        allyScript.LocalTargetBreachRadius = LocalTargetBreachRadius;
        allyScript.LocalTargetSeekRadius   = LocalTargetSeekRadius;
        allyScript.Home = gameObject;
        AllyHealth allyHealthScript = ally.GetComponent <AllyHealth>();

        allyHealthScript.Squad = Squad;
        Squad.Add(ally);
    }
Example #22
0
        private static void useRally()
        {
            var autoRally = Menu.Item("useRally").GetValue <bool>();
            var RallyHP   = Menu.Item("useRallyHP").GetValue <Slider>().Value;

            foreach (var Ally in ObjectManager.Get <AIHeroClient>().Where(Ally => Ally.IsAlly && !Ally.IsMe))
            {
                var allys = Menu.Item("useRally" + Ally.CharData);

                if (Player.InFountain() || Player.IsRecalling())
                {
                    return;
                }

                if (autoRally && ((Ally.Health / Ally.MaxHealth) * 100 <= RallyHP) && R.IsReady() &&
                    Player.CountEnemiesInRange(900) > 0 && (Ally.Distance(Player.Position) <= R.Range))
                {
                    if (allys != null && allys.GetValue <bool>())
                    {
                        R.Cast(Ally);
                    }
                }
            }
        }
Example #23
0
    //从PlayerInput脚本和/或“ Ally”按钮的OnClick()事件调用
    //Called from the PlayerInput scripts and / or the Ally button OnClick() event
    public void SummonAlly()
    {
        //如果没有盟友管理员,请离开
        //If there is no ally manager, leave
        if (allyManager == null)
        {
            return;
        }
        //通过调用SummonAlly()尝试获得盟友
        //Attempt to get an Ally by calling SummonAlly()
        Ally ally = allyManager.SummonAlly();

        //如果SummonAlly()能够产生盟友...
        //If SummonAlly() was able to spawn an ally...
        if (ally != null)
        {
            // ...将盟友设为敌人的目标...
            //...set the ally as the target of the enemies...
            EnemyTarget = ally.transform;
            // ...并在设置的延迟后调用UnsummonAlly()
            //...and call UnsummonAlly() after a set delay
            Invoke("UnSummonAlly", ally.Duration);
        }
    }
Example #24
0
    public static string CheckAdditionalAilment(Skill skill, Unit fromUnit, Unit toUnit)
    {
        string message = "";

        //状態異常の追加効果
        Dictionary <Ailment, int> additionalAilments = new Dictionary <Ailment, int>();

        //物理攻撃なら、武器の効果を追加
        if (skill.AttackType == AttackType.physics)
        {
            if (fromUnit.GetType() == typeof(Ally))
            {
                //武器の追加効果
                Ally ally = (Ally)fromUnit;
                foreach (KeyValuePair <Ailment, int> kvp in ally.EquippedWeapon.Ailments)
                {
                    if (kvp.Value > 0)
                    {
                        additionalAilments.Add(kvp.Key, kvp.Value);
                    }
                }
            }
        }

        //スキルの追加効果
        //if (skill.AdditionalAilment != Ailment.nothing)
        //{
        //    additionalAilments.Add(skill.AdditionalAilment);
        //}

        //状態異常の付与判定
        foreach (KeyValuePair <Ailment, int> kvp in additionalAilments)
        {
            if (!toUnit.Ailments.ContainsKey(kvp.Key))
            {
                int random = UnityEngine.Random.Range(0, 100);
                //int luk = fromUnit.Statuses[Status.LUK] * 2;
                //double mnt = (toUnit.Statuses[Status.MNT] + toUnit.Statuses[Status.LUK]) * 5;
                //int per = (int)((luk / mnt) * 100);
                int per = kvp.Value;

                if (toUnit.AilmentResists[kvp.Key] == 2)
                {
                    per = 0;
                }
                else if (toUnit.AilmentResists[kvp.Key] == 1)
                {
                    per = per / 2;
                }
                else if (toUnit.AilmentResists[kvp.Key] == -1)
                {
                    per = (int)(per * 1.5);
                }
                else if (toUnit.AilmentResists[kvp.Key] == -2)
                {
                    per = per * 2;
                }

                if (per > random)
                {
                    message += $"{toUnit.Name}は{kvp.Key.GetAilmentName()}状態になった!\n";
                    toUnit.SetAilment(kvp.Key);
                }
                else
                {
                }
            }
        }

        return(message);
    }
Example #25
0
 // Move ally to INDEX
 // Change both index and order
 private void MoveToIndex(Ally t, int index)
 {
     allies[index] = t;
     t.MoveToPosition(positions[index]);
     t.order = index;
 }
Example #26
0
 public AllyTurnTimer(Ally ally, long elapsed)
     : base(ally, elapsed)
 {
 }
Example #27
0
        private void SetControl()
        {
            // Check for disabled controlling ally
            if (_control != null)
                if (_control.CannotAct)
                    ClearControl();

            // Check turn timers and enqueue if up
            for (int i = 0; i < 3; i++)
                if (IsReady(_allies[i]))
                    _turnQueue.Enqueue(_allies[i]);

            // Check turn queue and set control if none set
            if (_control == null)
                if (_turnQueue.Count > 0)
                {
                    _control = _turnQueue.Dequeue();
                    Screen.PushControl(_control.BattleMenu);
                }
        }
Example #28
0
 private bool IsReady(Ally a)
 {
     bool ready = true;
     ready = ready && a != null; // they're not null
     ready = ready && a.TurnTimer.IsUp; // they're ready
     ready = ready && !_abilityQueue.Contains(a.Ability); // they're not in the ability queue
     ready = ready && _activeAbility != a.Ability; // they're not acting now
     ready = ready && !a.CannotAct; // they're able to act
     ready = ready && !_turnQueue.Contains(a); // they're not already in the turn queue
     ready = ready && _control != a; // they're not in control
     return ready;
 }
    private Ally makeAlly(jankFile input, character duck)
    {
        List <string>          sheetP        = new List <string>();
        List <Sprite[]>        sheets        = new List <Sprite[]>();
        List <SpriteAnimation> RPGanims      = new List <SpriteAnimation>();
        List <Skill>           skillList     = new List <Skill>();
        List <FighterSkill>    fighterSkills = new List <FighterSkill>();

        bool hasBack;

        int[] battlestats = new int[7];
        // Determine number of spritesheets
        string s = input.ReadLine();

        string[] split = s.Split(' ');
        int      paths = 0;

        int.TryParse(split[split.Length - 1], out paths);
        // Read paths for spritesheets
        for (int i = 0; i < paths; i++)
        {
            string   sheetPath = input.ReadLine();
            Sprite[] sheet     = Resources.LoadAll <Sprite>(@sheetPath);
            sheets.Add(sheet);
            sheetP.Add(sheetPath);
        }
        input.ReadLine();

        // Check if the character as a back set of animations
        s     = input.ReadLine();
        split = s.Split(' ');
        bool.TryParse(split[split.Length - 1], out hasBack);

        // Read in stats of character
        s     = input.ReadLine();
        split = s.Split(' ');
        for (int i = 1; i < split.Length; i++)
        {
            int.TryParse(split[i], out battlestats[i - 1]);
        }
        input.ReadLine();

        // Read in RPG animations
        for (int i = 0; i < 7; i++)
        {
            input.ReadLine();
            float fps;
            int   spriteAmt;

            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out fps);
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out spriteAmt);

            Sprite[] anim  = new Sprite[spriteAmt];
            string[] pathS = new string[spriteAmt];
            string[] nameS = new string[spriteAmt];
            for (int j = 0; j < spriteAmt; j++)
            {
                int sheetNum;
                s     = input.ReadLine();
                split = s.Split('-');
                int.TryParse(split[0], out sheetNum);
                pathS[j] = sheetP[sheetNum];
                nameS[j] = split[split.Length - 1];

                anim[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
            }

            SpriteAnimation entry = new SpriteAnimation(anim, new int[0], fps, true);
            entry.saveSprites(pathS, nameS);
            RPGanims.Add(entry);
            input.ReadLine();
        }

        input.ReadLine();
        int skillAmt;

        s     = input.ReadLine();
        split = s.Split(' ');
        int.TryParse(split[split.Length - 1], out skillAmt);
        input.ReadLine();

        // Read in RPG skills
        for (int i = 0; i < skillAmt; i++)
        {
            skillType       skill;
            string          atkName, des;
            element         atkEle;
            int             basePower, mpCost, range, effectChance;
            bool            isMagical, animLoop;
            float           start, end, fps;
            SpriteAnimation anim;

            battleType support    = battleType.NULL;
            status     statusMod  = status.NULL;
            int        scalar     = 0;
            stat       statBoost  = stat.NULL;
            bool       selfTarget = false;
            bool       targetAlly = false;
            string     skillSFX;

            atkName = input.ReadLine();
            des     = input.ReadLine();

            s     = input.ReadLine();
            split = s.Split(' ');
            if (split[split.Length - 1].CompareTo("Offensive") == 0)
            {
                skill = skillType.OFFENSIVE;

                // Attack element
                s      = input.ReadLine();
                split  = s.Split(' ');
                atkEle = decideEle(split[split.Length - 1]);

                // base power
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out basePower);

                // mp cost
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out mpCost);

                // is magical
                s     = input.ReadLine();
                split = s.Split(' ');
                bool.TryParse(split[split.Length - 1], out isMagical);

                // effect chance
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out effectChance);
                if (effectChance > 0)
                {
                    // status variables
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    support   = decideSupport(split[split.Length - 1]);
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    statusMod = decideStatus(split[split.Length - 1]);
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    statBoost = decideStat(split[split.Length - 1]);
                    s         = input.ReadLine();
                    split     = s.Split(' ');
                    int.TryParse(split[split.Length - 1], out scalar);
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    bool.TryParse(split[split.Length - 1], out selfTarget);
                    s     = input.ReadLine();
                    split = s.Split(' ');
                    bool.TryParse(split[split.Length - 1], out targetAlly);
                }

                // range
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out range);

                // positions
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out start);
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out end);

                // FPS
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out fps);

                // Sprite animation
                int spriteAmt;
                s     = input.ReadLine();
                split = s.Split(' ');
                if (split.Length > 2)
                {
                    int.TryParse(split[split.Length - 2], out spriteAmt);
                    animLoop = true;
                }
                else
                {
                    int.TryParse(split[split.Length - 1], out spriteAmt);
                    animLoop = false;
                }
                Sprite[] sprites = new Sprite[spriteAmt];
                string[] pathS   = new string[spriteAmt];
                string[] nameS   = new string[spriteAmt];
                for (int j = 0; j < spriteAmt; j++)
                {
                    int sheetNum;
                    s     = input.ReadLine();
                    split = s.Split('-');
                    int.TryParse(split[0], out sheetNum);

                    pathS[j] = sheetP[sheetNum];
                    nameS[j] = split[split.Length - 1];

                    sprites[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
                }
                anim = new SpriteAnimation(sprites, new int[0], fps, animLoop);
                anim.saveSprites(pathS, nameS);
            }
            else
            {
                skill        = skillType.SUPPORT;
                basePower    = 0;
                effectChance = 0;
                isMagical    = true;

                // Attack element
                s      = input.ReadLine();
                split  = s.Split(' ');
                atkEle = decideEle(split[split.Length - 1]);

                // mp cost
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out mpCost);

                // range
                s     = input.ReadLine();
                split = s.Split(' ');
                int.TryParse(split[split.Length - 1], out range);

                // positions
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out start);
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out end);

                // status variables
                s         = input.ReadLine();
                split     = s.Split(' ');
                support   = decideSupport(split[split.Length - 1]);
                s         = input.ReadLine();
                split     = s.Split(' ');
                statusMod = decideStatus(split[split.Length - 1]);
                s         = input.ReadLine();
                split     = s.Split(' ');
                statBoost = decideStat(split[split.Length - 1]);
                s         = input.ReadLine();
                split     = s.Split(' ');
                int.TryParse(split[split.Length - 1], out scalar);
                s     = input.ReadLine();
                split = s.Split(' ');
                bool.TryParse(split[split.Length - 1], out selfTarget);
                s     = input.ReadLine();
                split = s.Split(' ');
                bool.TryParse(split[split.Length - 1], out targetAlly);

                // FPS
                s     = input.ReadLine();
                split = s.Split(' ');
                float.TryParse(split[split.Length - 1], out fps);

                // Sprite animation
                int spriteAmt;
                s     = input.ReadLine();
                split = s.Split(' ');
                if (split.Length > 2)
                {
                    int.TryParse(split[split.Length - 2], out spriteAmt);
                    animLoop = true;
                }
                else
                {
                    int.TryParse(split[split.Length - 1], out spriteAmt);
                    animLoop = false;
                }
                Sprite[] sprites = new Sprite[spriteAmt];
                string[] pathS   = new string[spriteAmt];
                string[] nameS   = new string[spriteAmt];
                for (int j = 0; j < spriteAmt; j++)
                {
                    int sheetNum;
                    s     = input.ReadLine();
                    split = s.Split('-');
                    int.TryParse(split[0], out sheetNum);

                    pathS[j] = sheetP[sheetNum];
                    nameS[j] = split[split.Length - 1];

                    sprites[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
                }
                anim = new SpriteAnimation(sprites, new int[0], fps, animLoop);
                anim.saveSprites(pathS, nameS);
            }
            // Get SFX path
            input.ReadLine();
            skillSFX = input.ReadLine();
            input.ReadLine();

            Skill entry = new Skill(skill, atkName, des, atkEle, mpCost, range, start, end, anim, skillSFX);
            entry.setAttack(basePower, isMagical, effectChance);
            if (skill == skillType.SUPPORT || effectChance > 0)
            {
                entry.setSupport(support, statusMod, statBoost, scalar, selfTarget, targetAlly);
            }
            skillList.Add(entry);
        }

        input.ReadLine();
        s     = input.ReadLine();
        split = s.Split(' ');
        int.TryParse(split[split.Length - 1], out skillAmt);
        input.ReadLine();

        // Read fighter skills
        for (int i = 0; i < skillAmt; i++)
        {
            bool            hasProj;
            string          projPath = "";
            string          atkName = input.ReadLine();
            int             hitstun, basePower, faf, fps, rehit;
            float           xPow, yPow, xShift, yShift;
            bool            jc, sc, animLoop;
            SpriteAnimation anim, animB;
            string          skillSFX;

            // Projectile
            s     = input.ReadLine();
            split = s.Split(' ');
            bool.TryParse(split[split.Length - 1], out hasProj);
            if (hasProj)
            {
                projPath = input.ReadLine();
            }

            // Command Input
            int inputAmt;
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out inputAmt);
            KeyCode[] command = new KeyCode[inputAmt];
            s     = input.ReadLine();
            split = s.Split(' ');
            for (int j = 0; j < inputAmt; j++)
            {
                command[j] = decideKeyCode(split[j]);
            }

            // Hitstun
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out hitstun);

            // Base Power
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out basePower);

            // First Active Frame
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out faf);

            // Rehit
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out rehit);

            // Power and shift
            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out xPow);
            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out yPow);
            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out xShift);
            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out yShift);

            // Cancels
            s     = input.ReadLine();
            split = s.Split(' ');
            bool.TryParse(split[split.Length - 1], out jc);
            s     = input.ReadLine();
            split = s.Split(' ');
            bool.TryParse(split[split.Length - 1], out sc);

            // Hitbox Frames
            int frameAmt;
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out frameAmt);
            int[] hitFrames = new int[frameAmt];
            s = input.ReadLine();
            if (frameAmt == 1)
            {
                int.TryParse(s, out hitFrames[0]);
            }
            else if (frameAmt > 1)
            {
                split = s.Split('-');
                int min, max;
                int.TryParse(split[0], out min);
                int.TryParse(split[split.Length - 1], out max);
                for (int j = 0; j < hitFrames.Length; j++)
                {
                    hitFrames[j] = j + min;
                }
            }

            // Sprites
            int spriteAmt;
            s     = input.ReadLine();
            split = s.Split(' ');
            if (split.Length > 2)
            {
                int.TryParse(split[split.Length - 2], out spriteAmt);
                animLoop = true;
            }
            else
            {
                int.TryParse(split[split.Length - 1], out spriteAmt);
                animLoop = false;
            }
            Sprite[] sprites = new Sprite[spriteAmt];
            string[] pathS   = new string[spriteAmt];
            string[] nameS   = new string[spriteAmt];
            for (int j = 0; j < spriteAmt; j++)
            {
                int sheetNum;
                s     = input.ReadLine();
                split = s.Split('-');
                int.TryParse(split[0], out sheetNum);

                pathS[j] = sheetP[sheetNum];
                nameS[j] = split[split.Length - 1];

                sprites[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
            }

            // Sprites back
            Sprite[] spritesB = new Sprite[spriteAmt];
            string[] pathSB   = new string[spriteAmt];
            string[] nameSB   = new string[spriteAmt];
            if (hasBack)
            {
                for (int j = 0; j < spriteAmt; j++)
                {
                    int sheetNum;
                    s     = input.ReadLine();
                    split = s.Split('-');
                    int.TryParse(split[0], out sheetNum);

                    pathSB[j] = sheetP[sheetNum];
                    nameSB[j] = split[split.Length - 1];

                    spritesB[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
                }
            }

            // Hitboxes
            int hitboxAmt;
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out hitboxAmt);
            HitBox[] boxes = new HitBox[hitboxAmt];
            for (int j = 0; j < hitboxAmt; j++)
            {
                s     = input.ReadLine();
                split = s.Split(' ');
                float x, y, xs, ys;
                float.TryParse(split[0], out x);
                float.TryParse(split[1], out y);
                float.TryParse(split[2], out xs);
                float.TryParse(split[3], out ys);

                boxes[j] = new HitBox((x / 2) + xs, (y / 2) + ys, (-x / 2) + xs, (-y / 2) + ys);
            }

            // FPS
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out fps);
            anim = new SpriteAnimation(sprites, hitFrames, fps, animLoop);
            anim.saveSprites(pathS, nameS);
            animB = new SpriteAnimation(spritesB, hitFrames, fps, animLoop);
            animB.saveSprites(pathSB, nameSB);

            // Get SFX path
            input.ReadLine();
            skillSFX = input.ReadLine();

            FighterSkill entry = new FighterSkill(atkName, hitstun, basePower, faf, xPow, yPow, xShift, yShift, jc, sc, command, boxes, rehit, hitFrames, skillSFX);
            entry.setAnimation(anim);
            if (hasBack)
            {
                entry.setAnimationBack(animB);
            }
            if (hasProj)
            {
                entry.setProjectile(projPath, false);
            }
            fighterSkills.Add(entry);

            input.ReadLine();
        }
        float walkSpd, dashSpd, glideSpd, gravity;
        int   maxJumps;

        // Read in fighter variables
        s     = input.ReadLine();
        split = s.Split(' ');
        float.TryParse(split[split.Length - 1], out walkSpd);
        s     = input.ReadLine();
        split = s.Split(' ');
        float.TryParse(split[split.Length - 1], out dashSpd);
        s     = input.ReadLine();
        split = s.Split(' ');
        float.TryParse(split[split.Length - 1], out glideSpd);
        s     = input.ReadLine();
        split = s.Split(' ');
        float.TryParse(split[split.Length - 1], out gravity);
        s     = input.ReadLine();
        split = s.Split(' ');
        int.TryParse(split[split.Length - 1], out maxJumps);
        input.ReadLine();

        List <SpriteAnimation> fightAnims  = new List <SpriteAnimation>();
        List <SpriteAnimation> fightAnimsB = new List <SpriteAnimation>();

        for (int i = 0; i < 9; i++)
        {
            input.ReadLine();
            float fps;
            int   spriteCount;
            s     = input.ReadLine();
            split = s.Split(' ');
            float.TryParse(split[split.Length - 1], out fps);
            s     = input.ReadLine();
            split = s.Split(' ');
            int.TryParse(split[split.Length - 1], out spriteCount);

            Sprite[] sprites = new Sprite[spriteCount];
            string[] pathS   = new string[spriteCount];
            string[] nameS   = new string[spriteCount];
            for (int j = 0; j < spriteCount; j++)
            {
                int sheetNum;
                s     = input.ReadLine();
                split = s.Split('-');
                int.TryParse(split[0], out sheetNum);
                pathS[j]   = sheetP[sheetNum];
                nameS[j]   = split[split.Length - 1];
                sprites[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
            }
            SpriteAnimation entry = new SpriteAnimation(sprites, new int[0], fps, true);
            entry.saveSprites(pathS, nameS);
            fightAnims.Add(entry);

            if (hasBack)
            {
                pathS = new string[spriteCount];
                nameS = new string[spriteCount];
                for (int j = 0; j < spriteCount; j++)
                {
                    int sheetNum;
                    s     = input.ReadLine();
                    split = s.Split('-');
                    int.TryParse(split[0], out sheetNum);
                    pathS[j]   = sheetP[sheetNum];
                    nameS[j]   = split[split.Length - 1];
                    sprites[j] = getSprite(sheets[sheetNum], split[split.Length - 1]);
                }
                entry = new SpriteAnimation(sprites, new int[0], fps, true);
                entry.saveSprites(pathS, nameS);
                fightAnimsB.Add(entry);
            }

            input.ReadLine();
        }

        // Read in icons
        input.ReadLine();
        Sprite[] icons = new Sprite[4];
        string[] pathF = new string[3];
        string[] nameF = new string[3];
        string   pathW = "", nameW = "";

        for (int i = 0; i < icons.Length; i++)
        {
            int sheetNum;
            s     = input.ReadLine();
            split = s.Split('-');
            int.TryParse(split[0], out sheetNum);
            if (i < 3)
            {
                pathF[i] = sheetP[sheetNum];
                nameF[i] = split[split.Length - 1];
            }
            else
            {
                pathW = sheetP[sheetNum];
                nameW = split[split.Length - 1];
            }
            icons[i] = getSprite(sheets[sheetNum], split[split.Length - 1]);
        }

        Fighter streetDuck = new Fighter(walkSpd, dashSpd, glideSpd, gravity, maxJumps);

        streetDuck.setAnimations(fightAnims[0], fightAnims[1], fightAnims[2], fightAnims[3], fightAnims[4], fightAnims[5], fightAnims[6], fightAnims[7], fightAnims[8]);
        if (hasBack)
        {
            streetDuck.setBackAnimations(fightAnimsB[0], fightAnimsB[1], fightAnimsB[2], fightAnimsB[3], fightAnimsB[4], fightAnimsB[5], fightAnimsB[6], fightAnimsB[7], fightAnimsB[8]);
        }

        streetDuck.setNormals(fighterSkills[0], fighterSkills[1], fighterSkills[2]);
        streetDuck.setCrouches(fighterSkills[3], fighterSkills[4], fighterSkills[5]);
        streetDuck.setJumps(fighterSkills[6], fighterSkills[7], fighterSkills[8]);
        for (int i = 9; i < fighterSkills.Count; i++)
        {
            streetDuck.addSkill(fighterSkills[i]);
        }

        Ally ducky = new Ally(duck, streetDuck, battlestats);

        for (int j = 0; j < skillList.Count; j++)
        {
            ducky.addSkill(skillList[j]);
        }
        ducky.setAnimations(RPGanims[0], RPGanims[1], RPGanims[2], RPGanims[3], RPGanims[4], RPGanims[5], RPGanims[6]);
        ducky.setIcons(icons[0], icons[1], icons[2], icons[3]);
        ducky.saveIcons(pathF, nameF, pathW, nameW);
        return(ducky);
    }
Example #30
0
 public void ClearControl()
 {
     _control = null;
     Screen.ClearControl();
 }
Example #31
0
 // Use this for initialization
 void Start()
 {
     parent = transform.parent.GetComponent<Ally>();
     maxLife = parent.Life;
 }
Example #32
0
 public AllyTurnTimer(Ally ally, long elapsed)
     : base(ally, elapsed)
 {
 }
Example #33
0
 public void AddObj(Ally obj)
 {
     Allies.Add(obj);
 }
Example #34
0
        public BattleMenu(Ally a)
            : base(Globals.WIDTH / 4,
                Globals.HEIGHT * 7 / 10 + 10,
                Globals.WIDTH / 5,
                Globals.HEIGHT * 5 / 20 - 6)
        {
            Visible = false;

            // Always an option

            #region Item Menu

            foreach (Materia m in a.Materia)
                if (m != null && m.Name == "W-Item")
                    _witem = true;

            #endregion Item Menu

            // iterate through options
            int o = 0;

            #region Attack
            foreach (Materia m in a.Materia)
                if (m != null)
                {
                    if (m.ID == "doublecut")
                    {
                        if (m.Level == 0)
                        {
                            _doubleCutOption2 = o;
                            _doubleCutOption4 = -1;
                        }
                        else
                        {
                            _doubleCutOption4 = o;
                            _doubleCutOption2 = -1;
                        }
                        _slashAllOption = -1;
                        _flashOption = -1;
                    }
                    else if (m.ID == "slashall")
                    {
                        if (m.Level == 0)
                        {
                            _slashAllOption = o;
                            _flashOption = -1;
                        }
                        else
                        {
                            _flashOption = o;
                            _slashAllOption = -1;
                        }
                        _doubleCutOption2 = -1;
                        _doubleCutOption4 = -1;
                    }
                }
            if (_doubleCutOption2 == -1 && _doubleCutOption4 == -1 &&
                _slashAllOption == -1 && _flashOption == -1)
                _attackOption = o;
            o++;
            #endregion Attack

            // put this after every one in order to skip the Item option
            if (o == 3)
                o++;

            #region Magic Menu
            int c = 0;
            foreach (MagicSpell s in a.MagicSpells)
                c++;
            if (c > 0)
            {
                _magicMenuOption = o;
                o++;
                foreach (Materia m in a.Materia)
                    if (m != null && m.Name == "W-Magic")
                        _wmagic = true;
            }
            #endregion Magic Menu

            // put this after every one in order to skip the Item option
            if (o == 3)
                o++;

            #region Summon Menu
            c = 0;
            foreach (Summon s in a.Summons)
                c++;
            if (c > 0)
            {
                _summonMenuOption = o;
                o++;
                foreach (Materia m in a.Materia)
                    if (m != null && m.Name == "W-Summon")
                        _wsummon = true;
            }
            #endregion Summon Menu

            // put this after every one in order to skip the Item option
            if (o == 3)
                o++;

            #region Sense

            foreach (Materia m in a.Materia)
                if (m != null && m.Name == "Sense")
                {
                    _senseOption = o;
                    o++;
                }

            #endregion

            // put this after every one in order to skip the Item option
            if (o == 3)
                o++;

            #region Enemy Skill

            foreach (Materia m in a.Materia)
                if (m != null && m.ID == "enemyskill")
                {
                    _enemySkillMenuOption = o;
                    o++;
                }

            #endregion

            // put this after every one in order to skip the Item option
            if (o == 3)
                o++;

            #region Mime

            foreach (Materia m in a.Materia)
                if (m != null && m.ID == "mime")
                {
                    _mimeOption = o;
                    o++;
                }

            #endregion

            // put this after every one in order to skip the Item option
            if (o == 3)
                o++;

            #region Deathblow

            foreach (Materia m in a.Materia)
                if (m != null && m.ID == "deathblow")
                {
                    _deathblowOption = o;
                    o++;
                }

            #endregion

            // put this after every one in order to skip the Item option
            if (o == 3)
                o++;

            #region Steal

            foreach (Materia m in a.Materia)
                if (m != null && m.ID == "steal")
                {
                    if (m.Level == 0)
                    {
                        _stealOption = o;
                        _mugOption = -1;
                    }
                    else
                    {
                        _mugOption = o;
                        _stealOption = -1;
                    }
                }
            if (_mugOption != -1 || _stealOption != -1)
                o++;

            #endregion

            // put this after every one in order to skip the Item option
            if (o == 3)
                o++;

            _columns = (o - 1) / _rows + 1;
            if (_columns != 1)
                Width = W * _columns;
        }
Example #35
0
    void Update()
    {
        //make sure this is the local player and there are 2 castles in the scene
        if (!isLocalPlayer || FindObjectsOfType <GameManagerMultiplayer>().Length != 2)
        {
            return;
        }

        if (bombProgress < 1)
        {
            //when bomb is loading, set red color and disable button
            bombProgress += Time.deltaTime * bombLoadingSpeed;
            bombLoadingBar.GetComponent <Image>().color = Color.red;
            bombButton.GetComponent <Button>().enabled  = false;
        }
        else
        {
            //if bomb is done, set a blue color and enable the bomb button
            bombProgress = 1;
            bombLoadingBar.GetComponent <Image>().color = new Color(0, 1, 1, 1);
            bombButton.GetComponent <Button>().enabled  = true;
        }

        //set fillamount to the bomb progress
        bombLoadingBar.GetComponent <Image>().fillAmount = bombProgress;

        //ray from main camera
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit))
        {
            //check if left mouse button gets pressed
            if (Input.GetMouseButtonDown(0))
            {
                //if you didn't click on UI and you have not enought gold, display a warning
                if (gold < troops[selectedUnit].troopCosts && !EventSystem.current.IsPointerOverGameObject())
                {
                    StartCoroutine(GoldWarning());
                }
                //check if you hit any collider when clicking (just to prevent errors)
                if (hit.collider != null)
                {
                    //if you click battle ground, if click doesn't hit any UI, if space is not down and if you have enough gold:
                    if (hit.collider.gameObject.CompareTag("Battle ground") && !selectionMode && !isPlacingBomb && !EventSystem.current.IsPointerOverGameObject() &&
                        gold >= troops[selectedUnit].troopCosts && (!GameObject.Find("Mobile multiplayer") || (GameObject.Find("Mobile multiplayer") && MobileMultiplayer.deployMode)) &&
                        (!ownHalfOnly || (ownHalfOnly && ((transform.position.x < 0 && hit.point.x < -2) || (transform.position.x > 0 && hit.point.x > 2)))))
                    {
                        SpawnUnit(hit.point, null, false, false);
                        //get the amount of gold needed to spawn this unit
                        gold -= troops[selectedUnit].troopCosts;
                    }
                    //if the other side of the battle ground was clicked, and its not allowed, show a warning
                    else if (hit.collider.gameObject.CompareTag("Battle ground") && !selectionMode && !isPlacingBomb && !EventSystem.current.IsPointerOverGameObject() &&
                             gold >= troops[selectedUnit].troopCosts && (!GameObject.Find("Mobile multiplayer") || (GameObject.Find("Mobile multiplayer") && MobileMultiplayer.deployMode)) &&
                             ownHalfOnly && transform.position.x <0 && hit.point.x> -2)
                    {
                        StartCoroutine(deployWrongSideWarning(2));
                    }
                    //if the other side of the battle ground was clicked, and its not allowed, show a warning
                    else if (hit.collider.gameObject.CompareTag("Battle ground") && !selectionMode && !isPlacingBomb && !EventSystem.current.IsPointerOverGameObject() &&
                             gold >= troops[selectedUnit].troopCosts && (!GameObject.Find("Mobile multiplayer") || (GameObject.Find("Mobile multiplayer") && MobileMultiplayer.deployMode)) &&
                             ownHalfOnly && transform.position.x > 0 && hit.point.x < 2)
                    {
                        StartCoroutine(deployWrongSideWarning(1));
                    }

                    //if you are placing a bomb and click...
                    if (isPlacingBomb && !EventSystem.current.IsPointerOverGameObject())
                    {
                        //instantiate explosion

                        if (host)
                        {
                            GameObject explosion = Instantiate(bombExplosion, hit.point, Quaternion.identity);
                            NetworkServer.Spawn(explosion);

                            foreach (GameObject enemy in GameObject.FindGameObjectsWithTag("Player 2 unit"))
                            {
                                if (enemy != null && Vector3.Distance(enemy.transform.position, hit.point) <= BombRange / 2)
                                {
                                    //kill enemy if its within the bombrange
                                    enemy.GetComponent <CharacterMultiplayer>().lives = 0;
                                }
                            }
                        }
                        else
                        {
                            //use a command if this is not the host
                            CmdSpawnExplosion(hit.point);
                        }

                        //reset bomb progress
                        bombProgress  = 0;
                        isPlacingBomb = false;
                        bombRange.SetActive(false);
                    }
                    else if (hit.collider.gameObject.CompareTag("Battle ground") && isPlacingBomb && EventSystem.current.IsPointerOverGameObject())
                    {
                        //if you place a bomb and click any UI element, continue but don't reset bomb progress
                        isPlacingBomb = false;
                        bombRange.SetActive(false);
                    }
                }
            }
        }

        if (hit.collider != null && isPlacingBomb && !EventSystem.current.IsPointerOverGameObject())
        {
            //show the bomb range at mouse position using a spot light
            bombRange.transform.position = new Vector3(hit.point.x, 75, hit.point.z);
            //adjust spotangle to correspond to bomb range
            bombRange.GetComponent <Light>().spotAngle = BombRange;
            bombRange.SetActive(true);
        }

        //if space is down too set the position where you first clicked
        if (Input.GetMouseButtonDown(0) && selectionMode && !isPlacingBomb &&
            (!GameObject.Find("Mobile multiplayer") || (GameObject.Find("Mobile multiplayer") && !MobileMultiplayer.selectionModeMove)))
        {
            mouseDownPos = Input.mousePosition;
            isDown       = true;
            visible      = true;
        }

        // Continue tracking mouse position until mouse button is up
        if (isDown)
        {
            mouseLastPos = Input.mousePosition;
            //if you release mouse button, remove rectangle and stop tracking
            if (Input.GetMouseButtonUp(0))
            {
                isDown  = false;
                visible = false;
            }
        }

        //get all ally units according to the team
        if (host)
        {
            allies = GameObject.FindGameObjectsWithTag("Player 1 unit");
        }
        else
        {
            allies = GameObject.FindGameObjectsWithTag("Player 2 unit");
        }

        //if player presses d, deselect all characters
        if (Input.GetKey("x"))
        {
            foreach (GameObject Ally in allies)
            {
                if (Ally != null)
                {
                    Ally.GetComponent <CharacterMultiplayer>().selected = false;
                }
            }
        }

        //start selection mode when player presses spacebar
        if (Input.GetKeyDown("space"))
        {
            selectCharacters();
        }

        //update gold display
        goldBar.fillAmount = (gold / maxGold);
        goldText.text      = "" + gold;

        //color buttons grey if the unit is not deployable yet
        for (int i = 0; i < troops.Count; i++)
        {
            if (troops[i].troopCosts <= gold)
            {
                troops[i].button.gameObject.GetComponent <Image>().color = Color.white;
            }
            else
            {
                troops[i].button.gameObject.GetComponent <Image>().color = new Color(0.7f, 0.7f, 0.7f, 1);
            }
        }
    }
Example #36
0
        protected override void InternalInit()
        {
            foreach (Enemy e in _enemies)
                e.AIThread.Start();

            _control = null;
            Screen.Init();
        }
Example #37
0
 public void deleteObj(Ally Obj)
 {
     Allies.Remove(Obj);
     Destroy(Obj.gameObject);
     //Debug.Log("di");
 }
Example #38
0
    //Move to a random space from which target can be attacked, then attack
    void randomMoveAndAttack(Ally target)
    {
        List <Coord> possibleMoves = new List <Coord>();

        System.Random randomMove           = new System.Random(Time.realtimeSinceStartup.ToString().GetHashCode());
        List <Coord>  checkedPossibleMoves = new List <Coord>();

        if (atkRange == 1)
        {
            //move adjacent to target and attack
            possibleMoves.Add(new Coord(target.position.X + 1, target.position.Y));
            possibleMoves.Add(new Coord(target.position.X - 1, target.position.Y));
            possibleMoves.Add(new Coord(target.position.X, target.position.Y - 1));
            possibleMoves.Add(new Coord(target.position.X, target.position.Y + 1));

            //Enemy must move to an unoccupied tile within its move range
            Coord chosenMove;
            do
            {
                chosenMove = possibleMoves[randomMove.Next(0, possibleMoves.Count)];
                if (!checkedPossibleMoves.Contains(chosenMove))
                {
                    checkedPossibleMoves.Add(chosenMove);
                }
                if (checkedPossibleMoves.Count == possibleMoves.Count)
                {
                    return;
                }
            } while(!validSpaces.ContainsKey(chosenMove) || occupiedSpaces.Contains(chosenMove));
            moveUnit(chosenMove);
            attack(target, false);
        }
        else if (atkRange == 2)
        {
            //move 2 away from target and attack
            possibleMoves.Add(new Coord(target.position.X + 1, target.position.Y + 1));
            possibleMoves.Add(new Coord(target.position.X + 1, target.position.Y - 1));
            possibleMoves.Add(new Coord(target.position.X + 2, target.position.Y));
            possibleMoves.Add(new Coord(target.position.X - 1, target.position.Y + 1));
            possibleMoves.Add(new Coord(target.position.X - 1, target.position.Y - 1));
            possibleMoves.Add(new Coord(target.position.X - 2, target.position.Y));
            possibleMoves.Add(new Coord(target.position.X, target.position.Y + 2));
            possibleMoves.Add(new Coord(target.position.X, target.position.Y - 2));

            //Enemy must move to an unoccupied tile within its move range
            Coord chosenMove;
            do
            {
                chosenMove = possibleMoves[randomMove.Next(0, possibleMoves.Count)];
                if (!checkedPossibleMoves.Contains(chosenMove))
                {
                    checkedPossibleMoves.Add(chosenMove);
                }
                if (checkedPossibleMoves.Count == possibleMoves.Count)
                {
                    return;
                }
            } while(!validSpaces.ContainsKey(chosenMove) || occupiedSpaces.Contains(chosenMove));
            moveUnit(chosenMove);
            attack(target, false);
        }
    }
Example #39
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);



            TextExtents te;

            string exp, next, llvl;


            #region Top Row

            DrawCharacterStatus(d, g);

            exp  = Party.Selected.Exp.ToString();
            next = Party.Selected.ExpToNextLevel.ToString();
            llvl = Party.Selected.LimitLevel.ToString();

            Text.ShadowedText(g, "Exp:", X + x8, Y + ya);
            Text.ShadowedText(g, "Next lvl:", X + x8, Y + yb);
            Text.ShadowedText(g, "Limit lvl:", X + x8, Y + yc);

            te = g.TextExtents(exp);
            Text.ShadowedText(g, exp, X + x11 - te.Width, Y + ya);
            te = g.TextExtents(next);
            Text.ShadowedText(g, next, X + x11 - te.Width, Y + yb);
            te = g.TextExtents(llvl);
            Text.ShadowedText(g, llvl, X + x11 - te.Width, Y + yc);

            #endregion Top


            #region Left

            string str, vit, dex, mag, spi, lck;
            string atk, atkp, def, defp, mat, mdf, mdfp;

            str = Party.Selected.Strength.ToString();
            vit = Party.Selected.Vitality.ToString();
            dex = Party.Selected.Dexterity.ToString();
            mag = Party.Selected.Magic.ToString();
            spi = Party.Selected.Spirit.ToString();
            lck = Party.Selected.Luck.ToString();

            atk  = Ally.Attack(Party.Selected).ToString();
            atkp = Ally.AttackPercent(Party.Selected).ToString();
            def  = Ally.Defense(Party.Selected).ToString();
            defp = Ally.DefensePercent(Party.Selected).ToString();
            mat  = Ally.MagicAttack(Party.Selected).ToString();
            mdf  = Ally.MagicDefense(Party.Selected).ToString();
            mdfp = Ally.MagicDefensePercent(Party.Selected).ToString();

            Cairo.Color greenish = Colors.TEXT_TEAL;

            Text.ShadowedText(g, greenish, "Strength", X + x0, Y + yq + (line * 0));
            Text.ShadowedText(g, greenish, "Vitality", X + x0, Y + yq + (line * 1));
            Text.ShadowedText(g, greenish, "Dexterity", X + x0, Y + yq + (line * 2));
            Text.ShadowedText(g, greenish, "Magic", X + x0, Y + yq + (line * 3));
            Text.ShadowedText(g, greenish, "Spirit", X + x0, Y + yq + (line * 4));
            Text.ShadowedText(g, greenish, "Luck", X + x0, Y + yq + (line * 5));

            Text.ShadowedText(g, greenish, "Attack", X + x0, Y + yr + (line * 0));
            Text.ShadowedText(g, greenish, "Attack %", X + x0, Y + yr + (line * 1));
            Text.ShadowedText(g, greenish, "Defense", X + x0, Y + yr + (line * 2));
            Text.ShadowedText(g, greenish, "Defense %", X + x0, Y + yr + (line * 3));
            Text.ShadowedText(g, greenish, "Magic", X + x0, Y + yr + (line * 4));
            Text.ShadowedText(g, greenish, "Magic def", X + x0, Y + yr + (line * 5));
            Text.ShadowedText(g, greenish, "Magic def %", X + x0, Y + yr + (line * 6));

            te = g.TextExtents(str);
            Text.ShadowedText(g, str, X + x1 - te.Width, Y + yq + (line * 0));
            te = g.TextExtents(vit);
            Text.ShadowedText(g, vit, X + x1 - te.Width, Y + yq + (line * 1));
            te = g.TextExtents(dex);
            Text.ShadowedText(g, dex, X + x1 - te.Width, Y + yq + (line * 2));
            te = g.TextExtents(mag);
            Text.ShadowedText(g, mag, X + x1 - te.Width, Y + yq + (line * 3));
            te = g.TextExtents(spi);
            Text.ShadowedText(g, spi, X + x1 - te.Width, Y + yq + (line * 4));
            te = g.TextExtents(lck);
            Text.ShadowedText(g, lck, X + x1 - te.Width, Y + yq + (line * 5));

            te = g.TextExtents(atk);
            Text.ShadowedText(g, atk, X + x1 - te.Width, Y + yr + (line * 0));
            te = g.TextExtents(atkp);
            Text.ShadowedText(g, atkp, X + x1 - te.Width, Y + yr + (line * 1));
            te = g.TextExtents(def);
            Text.ShadowedText(g, def, X + x1 - te.Width, Y + yr + (line * 2));
            te = g.TextExtents(defp);
            Text.ShadowedText(g, defp, X + x1 - te.Width, Y + yr + (line * 3));
            te = g.TextExtents(mat);
            Text.ShadowedText(g, mat, X + x1 - te.Width, Y + yr + (line * 4));
            te = g.TextExtents(mdf);
            Text.ShadowedText(g, mdf, X + x1 - te.Width, Y + yr + (line * 5));
            te = g.TextExtents(mdfp);
            Text.ShadowedText(g, mdfp, X + x1 - te.Width, Y + yr + (line * 6));

            #endregion Left


            #region Right



            MateriaSlots.Render(g, Party.Selected.Weapon, X + x9, Y + yi);
            MateriaSlots.Render(g, Party.Selected.Armor, X + x9, Y + yk);



            g.Color = Colors.TEXT_TEAL;
            g.MoveTo(X + x7, Y + yh);
            g.ShowText("Wpn.");
            g.MoveTo(X + x7, Y + yj);
            g.ShowText("Arm.");
            g.MoveTo(X + x7, Y + yl);
            g.ShowText("Acc.");
            g.Color = Colors.WHITE;

            Text.ShadowedText(g, Party.Selected.Weapon.Name, X + x8, Y + yh);
            Text.ShadowedText(g, Party.Selected.Armor.Name, X + x8, Y + yj);
            Text.ShadowedText(g, Party.Selected.Accessory.Name, X + x8, Y + yl);

            #endregion Right
        }
Example #40
0
 public WMagic(Ally ally, IEnumerable <MagicMenuEntry> spells, Menu.ScreenState screenState)
     : base(ally, spells, screenState)
 {
 }
Example #41
0
        public void StealItem(Ally thief)
        {
            int diff = 40 + Level - thief.Level;
            int stealMod = 512 * diff / 100;

            foreach (EnemyItem item in _steal)
            {
                int chance = item.Chance * stealMod / 256;
                int r = Game.Random.Next(64);
                if (r <= chance)
                {
                    Inventory.AddToInventory(item.Item);
                    _steal.Clear();
                    return;
                }
            }
            //if (_steal.Count == 0)
            //    ; // Nothing to steal
            //else ; // Couldn't steal anything
        }