Exemple #1
0
    void PopulatePlayer(TileProxy[] sideTiles)
    {
        PlayerMeta player = BaseSaver.GetPlayer();
        //Queue<TileProxy> validTls = new Queue<TileProxy>(GetSideTiles(BoardProxy.PLAYER_TEAM));
        Queue <TileProxy> validTls = new Queue <TileProxy>(sideTiles);
        List <UnitProxy>  units    = new List <UnitProxy>();
        List <Unit>       roster   = new List <Unit>(player.characters);

        roster.Reverse();
        //Debug.Log("PopulatePlayer: " + validTls.Count.ToString());
        List <Unit> inactiveUnits = new List <Unit>();

        for (int i = 3; i < roster.Count; i++)
        {
            inactiveUnits.Add(roster[i]);
        }

        for (int i = 0; i < roster.Count && i < 3; i++)
        {
            Unit cMeta = new Unit(roster[i]);
            //UnitProxy goodGuy = Instantiate(glossary.GetComponent<Glossary>().units[PLAYER_TEAM], transform);
            UnitProxy goodGuy = Instantiate(ClassNode.ComputeClassBaseUnit(cMeta.GetFactionType(),
                                                                           cMeta.GetUnitType(), glossary.GetComponent <Glossary>()), transform);
            units.Add(goodGuy);
            cMeta = ClassNode.ApplyClassBonusesBattle(cMeta, inactiveUnits.ToArray());
            goodGuy.PutData(cMeta);
            goodGuy.Init();
            TileProxy popTile = validTls.Dequeue();
            popTile.ReceiveGridObjectProxy(goodGuy);
            goodGuy.SnapToCurrentPosition();
            //Debug.Log("goodGuy placed at: " + popTile.GetPosition().ToString());
        }
    }
    //public void ResetAtThis()
    //{
    //    StartCoroutine(ResetTiles());
    //}

    public override void OnUnitSelected(UnitProxy obj)
    {
        if (currentUnit == null)
        {
            UnHighlightTiles();
            currentUnit = obj;
            //The maximum range in which a player has actions
            allTiles = BoardProxy.instance.GetAllVisitableNodes(obj, obj.GetMoveSpeed() > obj.GetAttackRange() ? obj.GetMoveSpeed() : obj.GetAttackRange(), true);
            //The attackable tiles
            attackableTiles = BoardProxy.instance.GetAllVisitableNodes(obj, obj.GetAttackRange(), true);
            //The visitable tiles
            visitableTiles = BoardProxy.instance.GetAllVisitableNodes(obj, obj.GetMoveSpeed());
            HighlightTiles(obj);
            PanelController.SwitchChar(obj);
        }
        else
        {
            if (obj.GetData().GetTeam() != currentUnit.GetData().GetTeam() &&
                allTiles.Contains(BoardProxy.instance.GetTileAtPosition(obj.GetPosition())) &&
                currentUnit.GetData().GetTurnActions().CanAttack())
            {
                if (obj.IsAttacked(currentUnit))
                {
                    //If the unit has died, remove it from the board and destroy the gameobject
                    BoardProxy.instance.GetTileAtPosition(obj.GetPosition()).RemoveGridObjectProxy(obj);
                    Destroy(obj.gameObject);
                    ConditionTracker.instance.EvaluateGame();
                    //Turn off the tiles
                    StartCoroutine(ResetTiles());
                }
                OnDisable();
                PanelController.SwitchChar(currentUnit);
            }
        }
    }
            public DOCollection DO <T>(string propertyname, params KeyValuePair <string, object>[] param) where T : DODBaseUnit
            {
                DODParameter pp = new DODParameter();

                pp.PropertyName = propertyname;
                foreach (var val in _driver._p.Domain(DomainKey.INPUT_PARAMETER))
                {
                    pp.SetValue(val.Key, val.Value);
                }
                foreach (var val in _driver._p.Domain(DomainKey.CONFIG))
                {
                    pp.SetValue(DomainKey.CONFIG, val.Key, val.Value);
                }
                if (param != null)
                {
                    foreach (var val in param)
                    {
                        pp.SetValue(val.Key, val.Value);
                    }
                }
                pp.FlowInstanceID = _driver._p.FlowInstanceID;
                pp.SetValue(ParameterKey.RESOURCE_MANAGER, _driver._p.Resources);
                pp.SetValue(ParameterKey.TOKEN, _driver._p.CurrentTransToken);
                var result = (DOCollection)UnitProxy <DODParameter> .Call <T>(pp);

                return(result);
            }
Exemple #4
0
 public Path <TileProxy> GetPathAIConsideration(TileProxy from, TileProxy to, UnitProxy thingToMove, bool allTiles = false)
 {
     return(PathGenerator.FindPath(from,
                                   to,
                                   GetDistanceFunctionAI(thingToMove, allTiles),
                                   GetEstimationFunction(to, thingToMove)));//might not want to use a list
 }
 private void HighlightTiles(UnitProxy obj)
 {
     foreach (var tile in allTiles)
     {
         tile.HighlightSelectedAdv(obj, visitableTiles, attackableTiles);
     }
 }
Exemple #6
0
    IEnumerator GenerateAttackAnims(UnitProxy oppUnit, GameObject baseProj, Vector3 start, Vector3 finish)
    {
        TileProxy dTile = BoardProxy.instance.GetTileAtPosition(GetPosition());

        dTile.CreateAnimation(Glossary.GetAtkFx(oppUnit.GetData().GetFactionType(), oppUnit.GetData().GetUnitType()), AnimationInteractionController.NO_WAIT);
        yield return(null);
    }
    static void LoadEnemyPanel(UnitProxy unit, int hpMissing = 0)
    {
        List <UnitProxy> remainingEnemies = new List <UnitProxy>(instance.enemies.Where(unt => unt.GetData().GetCurrHealth() > 0));

        remainingEnemies.Remove(unit);
        LoadPanelSuite(instance.enemyMain, instance.enemySub1, instance.enemySub2, instance.enemySub3, unit, remainingEnemies, hpMissing);
    }
    static void LoadPlayerPanel(UnitProxy unit, int hpMissing = 0)
    {
        List <UnitProxy> remainingPlayers = new List <UnitProxy>(instance.players.Where(unt => unt.GetData().GetCurrHealth() > 0));

        remainingPlayers.Remove(unit);
        LoadPanelSuite(instance.playerMain, instance.playerSub1, instance.playerSub2, instance.playerSub3, unit, remainingPlayers, hpMissing);
    }
Exemple #9
0
 IEnumerator AttackAnim(UnitProxy oppUnit, Animator anim, Transform opp, Vector3Int diff, string msg, bool showProjectiles = true)
 {
     if (anim != null && showProjectiles)
     {
         Vector3 theScale = opp.localScale;
         if (diff.x > 0)
         {
             //Debug.Log("right");
             theScale.x = -1;
             anim.SetBool("IDLE_FRONT_LEFT", false);
             while (anim.GetBool("IDLE_FRONT_LEFT"))
             {
             }
             anim.SetTrigger("ATK_BACK_LEFT");
         }
         else if (diff.x < 0)
         {
             //Debug.Log("left");
             theScale.x = 1;
             anim.SetBool("IDLE_FRONT_LEFT", true);
             while (!anim.GetBool("IDLE_FRONT_LEFT"))
             {
             }
             anim.SetTrigger("ATK_FRONT_LEFT");
         }
         else
         {
             //Defender is right below or above attacker
             if (diff.y > 0)
             {
                 //Debug.Log("up");
                 theScale.x = 1;
                 anim.SetBool("IDLE_FRONT_LEFT", false);
                 while (anim.GetBool("IDLE_FRONT_LEFT"))
                 {
                 }
                 anim.SetTrigger("ATK_BACK_LEFT");
             }
             else if (diff.y < 0)
             {
                 //Debug.Log("down");
                 theScale.x = -1;
                 anim.SetBool("IDLE_FRONT_LEFT", true);
                 while (!anim.GetBool("IDLE_FRONT_LEFT"))
                 {
                 }
                 anim.SetTrigger("ATK_FRONT_LEFT");
             }
         }
         opp.localScale = theScale;
     }
     Debug.Log("AttackAnim");
     FloatUp(Skill.Actions.DidAttack, msg, Color.red, "Was attacked", true);
     if (showProjectiles)
     {
         StartCoroutine(CreateProjectiles(oppUnit, opp.position));
     }
     yield return(null);
 }
Exemple #10
0
    public override void RouteBehavior(Actions action, UnitProxy u1, UnitProxy u2, List <TileProxy> path)
    {
        switch (action)
        {
        case Actions.BeginGame: BeginningGame(u1); break;

        default: return;
        }
    }
Exemple #11
0
    public override void RouteBehavior(Actions action, UnitProxy u1, UnitProxy u2, List <TileProxy> path)
    {
        switch (action)
        {
        case Actions.DidAttack: DidAttack(u1, u2); break;

        default: return;
        }
    }
Exemple #12
0
    public override void RouteBehavior(Actions action, UnitProxy u1, UnitProxy u2, List <TileProxy> path)
    {
        switch (action)
        {
        case Actions.EndedTurn: EndTurn(u1); break;

        default: return;
        }
    }
Exemple #13
0
    public List <TileProxy> GetAllVisitableNodes(UnitProxy thingToMove, int rng, bool allTiles = false)
    {
        var startNode = GetTileAtPosition(thingToMove.GetPosition());

        return(PathGenerator.FindAllVisitableNodes(startNode,
                                                   rng,
                                                   GetDistanceFunction(thingToMove, allTiles))
               .ToList());
    }
Exemple #14
0
    public void DecrementTileEffects()
    {
        //if (OnFire() && HasUnit()) {
        //    //Only injure unit from fire if it's that unit's team's turn
        //    if (GetUnit().GetData().GetTeam() == TurnController.instance.currentTeam && GetUnit().IsAttackedEnvironment(1)){
        //        if (unitThatSetTileOnFire != null) {
        //            unitThatSetTileOnFire.GetData().SetLvl(unitThatSetTileOnFire.GetData().GetLvl() + 1);
        //        }
        //        ConditionTracker.instance.EvalDeath(GetUnit());
        //    }
        //}

        if (IsDivine() && HasUnit())
        {
            //Divine tiles heal
            if (GetUnit().GetData().GetTeam() == TurnController.instance.currentTeam)
            {
                FloatUp(Skill.Actions.None, "+1", Color.green, "Healed from tile");
                GetUnit().GetData().SetCurrHealth(GetUnit().GetData().GetCurrHealth() + 1);
            }
        }

        //if (Frozen() && HasUnit()) {
        //    //Snow tiles apply enfeeble and rooted at the end of the turn
        //    if (GetUnit().GetData().GetTeam() == TurnController.instance.currentTeam && stuckUnit != GetUnit()){
        //        stuckUnit = GetUnit();
        //        FloatUp(Skill.Actions.None, "enfeebled", Color.red, "Enfeebled from tile");
        //        FloatUp(Skill.Actions.None, "rooted", Color.red, "Rooted from tile");
        //        GetUnit().GetData().GetTurnActions().EnfeebledForTurns(1);
        //        GetUnit().GetData().GetTurnActions().RootForTurns(1);
        //    } else if (GetUnit().GetData().GetTeam() == TurnController.instance.currentTeam && stuckUnit == GetUnit()){
        //        stuckUnit = null;
        //    }
        //}

        if (!IsWall() && HasObstacle())
        {
            RemoveGridObjectProxy(GetObstacle());
        }

        wallTrns   = wallTrns - 1 > 0 ? wallTrns - 1 : 0;
        divineTrns = divineTrns - 1 > 0 ? divineTrns - 1 : 0;
        snowTrns   = snowTrns - 1 > 0 ? snowTrns - 1 : 0;
        fireTrns   = fireTrns - 1 > 0 ? fireTrns - 1 : 0;

        if (!OnFire() && !IsWall() && !Frozen() && !IsDivine())
        {
            GetComponent <SpriteRenderer>().sprite = def;
            GetComponent <SpriteRenderer>().color  = Color.white;
            unitThatSetTileOnFire = null;
        }
        else
        {
            CheckAll();
        }
    }
Exemple #15
0
    /*
     * Fire
     */

    public void SetTurnsOnFire(int trns, UnitProxy unit)
    {
        unitThatSetTileOnFire = unit;
        if (fireTrns == 0)
        {
            ResetTile();
        }
        fireTrns += trns;
        CheckFire();
    }
Exemple #16
0
    /*
     * Snow
     */

    public void SetTurnsFrozen(int trns, UnitProxy unit)
    {
        unitThatSetTileOnFire = unit;
        if (snowTrns == 0)
        {
            ResetTile();
        }
        snowTrns += trns;
        CheckFrozen();
    }
Exemple #17
0
    /*
     * Wall
     */

    public void SetTurnsWall(int trns, UnitProxy unit)
    {
        unitThatSetTileOnFire = unit;
        if (wallTrns == 0)
        {
            ResetTile();
        }
        wallTrns += trns;
        CheckWall();
    }
 void SetCharAtkRng(UnitProxy unit)
 {
     if (unit == null)
     {
         AtkRngPnl.SetActive(false);
         return;
     }
     AtkRngPnl.SetActive(true);
     AtkRngPnl.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = unit.GetData().GetAtkRange().ToString();
 }
Exemple #19
0
    /*
     * Divine
     */

    public void SetTurnsDivine(int trns, UnitProxy unit)
    {
        unitThatSetTileOnFire = unit;
        if (divineTrns == 0)
        {
            ResetTile();
        }
        divineTrns += trns;
        CheckDivine();
    }
 void SetCharMv(UnitProxy unit)
 {
     if (unit == null)
     {
         MvPnl.SetActive(false);
         return;
     }
     MvPnl.SetActive(true);
     MvPnl.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = unit.GetData().GetMoveSpeed().ToString();
 }
Exemple #21
0
    IEnumerator FloatUpAnim(string msg, Color color, float wait, Transform oTransform, bool shakeChar = false, bool deathConsideration = false)
    {
        yield return(new WaitForSeconds(wait));

        //Debug.Log("FloatUpAnim");
        if (oTransform != null)
        {
            Vector3 pos = oTransform.position;
            //Debug.Log("FloatUpAnim pos: " + pos.ToString());
            //pos.x += .3f;
            //pos.y += 1f;
            if (oTransform.GetComponent <TileProxy>() != null)
            {
                pos.x -= .3f;
                pos.y += .5f;
            }
            else
            {
                //pos.x -= .3f;
                pos.y += 1f;
            }
            if (shakeChar)
            {
                yield return(new WaitForSeconds(.2f));

                oTransform.GetComponent <UnitProxy>().Shake();
                PlayImpactSound();
            }
            if (deathConsideration)
            {
                UnitProxy unit = oTransform.GetComponent <UnitProxy>();
                if (unit.GetData().IsDead())
                {
                    ConditionTracker.instance.EvalDeath(unit);
                }
            }
            else
            {
                GameObject numObj = new GameObject();
                numObj.transform.position = pos;
                numObj.transform.rotation = Quaternion.identity;
                numObj.transform.parent   = oTransform;
                numObj.AddComponent <TextMesh>();
                numObj.GetComponent <MeshRenderer>().sortingLayerName = "Emotes";
                numObj.GetComponent <TextMesh>().characterSize        = .2f;
                numObj.GetComponent <TextMesh>().text  = msg;
                numObj.GetComponent <TextMesh>().color = color;
                iTween.ShakePosition(numObj, new Vector3(0, .5f, 0), .3f);
                iTween.MoveTo(numObj, new Vector3(pos.x, pos.y + .3f, pos.z), .3f);
                yield return(new WaitForSeconds(.4f));

                Destroy(numObj);
            }
        }
    }
Exemple #22
0
    void PopulateClassesPanel()
    {
        classPnl.SetActive(true);
        classBtn.GetComponent <Outline>().effectColor = Color.red;
        GameMeta game      = BaseSaver.GetGame();
        string   pnlString = "";

        classPnl.transform.GetChild(1).GetChild(0).GetChild(0).GetComponent <TextMeshProUGUI>().text = pnlString;
        classPnl.transform.GetChild(1).GetChild(1).GetChild(0).GetComponent <Animator>().runtimeAnimatorController = null;
        classPnl.transform.GetChild(1).GetChild(1).GetChild(0).GetComponent <ImageAnimation>().Flush();
        classPnl.transform.GetChild(1).GetChild(2).GetComponent <TextMeshProUGUI>().text = pnlString;
        classPnl.transform.GetChild(1).GetChild(3).GetComponent <TextMeshProUGUI>().text = pnlString;

        string[] clssSeen = game.classesSeen.Where(clss => !(clss.Contains("BaseMage") || clss.Contains("BaseScout") || clss.Contains("BaseSoldier"))).ToArray();

        if (clssSeen.Length > 0)
        {
            game.classesSeen = game.classesSeen.OrderBy(nm => nm).ToArray();

            classPnl.transform.GetChild(0).GetChild(0).GetComponent <RectTransform>().sizeDelta = new Vector2(800, 150 * game.classesSeen.Length);

            foreach (Transform child in classPnl.transform.GetChild(0).GetChild(0))
            {
                Destroy(child.gameObject);
            }

            //string[] clssSeen = game.classesSeen.Where(clss => !(clss.Contains("BaseMage") || clss.Contains("BaseScout") || clss.Contains("BaseSoldier"))).ToArray();

            for (int i = 0; i < clssSeen.Length; i++)
            {
                //foreach(string clss in game.classesSeen.Where(clss => !(clss.Contains("BaseMage") || clss.Contains("BaseScout") || clss.Contains("BaseSoldier"))).ToArray()){
                string     clss    = clssSeen[i];
                GameObject clssCpy = Instantiate(clssRw, classPnl.transform.GetChild(0).GetChild(0));
                clssCpy.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = ClassNode.FormatClass(clss);
                ClassNode nde      = StaticClassRef.GetClass((StaticClassRef.AvailableClasses)Enum.Parse(typeof(StaticClassRef.AvailableClasses), clss));
                UnitProxy baseUnit = ClassNode.ComputeClassBaseUnit(nde, glossy);
                clssCpy.transform.GetChild(1).GetComponent <Image>().sprite         = baseUnit.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite;
                clssCpy.transform.GetChild(2).GetComponent <TextMeshProUGUI>().text = " " + ClassNode.GetFactionFromClass(clss);
                clssCpy.GetComponent <Button>().onClick.AddListener(() => {
                    instance.SetClassInfoText("Battle Bonus: " + StaticClassRef.GetFullClassDescription(clss) + "\n\nInactive Bonus: " + nde.ClassInactiveDesc(), StaticClassRef.GetClassByReference(clss).ClassName(),
                                              ClassNode.GetClassHeirarchyString(nde));
                    instance.SetClassSpriteAnimator(baseUnit.transform.GetChild(0).GetComponent <Animator>());
                });
                if (i == 0)
                {
                    clssCpy.GetComponent <Button>().onClick.Invoke();
                }
            }
            classPnl.transform.GetChild(0).GetComponent <ScrollRect>().normalizedPosition = new Vector2(0, 1);
        }
        else
        {
            SetClassInfoText("", "", "No classes found yet... Explore a little bit more and maybe something will be here!");
        }
    }
Exemple #23
0
 public override void DidAttack(UnitProxy attacker, UnitProxy defender)
 {
     foreach (TileProxy tl in BoardProxy.instance.GetAllVisitableNodes(defender, value, true))
     {
         if (!tl.HasObstacle())
         {
             tl.CreateAnimation(Glossary.fx.fireBaseSmall, AnimationInteractionController.ATK_WAIT);
             tl.SetTurnsOnFire(2, attacker);
         }
     }
 }
        public ProductController(ILogger <HomeController> logger
                                 , IConfiguration config, IHttpClientFactory httpClient, IHttpContextAccessor accessor
                                 , IWebHostEnvironment hostingEnvironment)
        {
            var token = accessor.HttpContext.User.Claims.First(x => x.Type == "token").Value;

            this._productProxy  = new ProductProxy(config, httpClient, token);
            this._categoryProxy = new CategoryProxy(config, httpClient, token);
            this._unitProxy     = new UnitProxy(config, httpClient, token);
            _hostingEnvironment = hostingEnvironment;
        }
Exemple #25
0
 Func <TileProxy, double> GetEstimationFunction(TileProxy destination, UnitProxy thingToMove)
 {
     return((t) =>
     {
         Vector3Int t1Pos = t.GetPosition();
         Vector3Int t2Pos = destination.GetPosition();
         int xdiff = Mathf.Abs(t1Pos.x - t2Pos.x);
         int ydiff = Mathf.Abs(t1Pos.y - t2Pos.y);
         return xdiff + ydiff;
     });
 }
 public static void SwitchChar(UnitProxy unit)
 {
     instance.SwitchCharImages(unit);
     instance.SwitchCharName(unit);
     instance.SetTeam(unit);
     instance.SetCharHealth(unit);
     instance.SetCharAttack(unit);
     instance.SetCharMv(unit);
     instance.SetTurnText(unit);
     instance.SetTypeText(unit);
     instance.SetCharAtkRng(unit);
 }
Exemple #27
0
    public bool IsAttacked(UnitProxy oppUnit, bool useAttack = true)
    {
        Debug.Log("IsAttacked");
        if (useAttack)
        {
            oppUnit.GetData().GetTurnActions().Attack();
        }
        PanelControllerNew.SwitchChar(oppUnit);

        //Damage the unit

        /*
         * Trigger the opponent's attack trigger here
         */

        Vector3Int animStart = oppUnit.GetPosition();
        Vector3Int animEnd   = GetPosition();

        Debug.Log("animStart: " + animStart.ToString());
        Debug.Log("animEnd: " + animEnd.ToString());

        Vector3Int diff = animEnd - animStart;

        if (_data.GetAegis())
        {
            Debug.Log("Aegis!");
            //_data.SetAegis(false);
            StartCoroutine(AttackAnim(oppUnit, oppUnit.gameObject.transform.GetChild(0).GetComponent <Animator>(),
                                      oppUnit.gameObject.transform, diff, "", useAttack));
            //LostAegisAnim();
            SetAegis(false, AnimationInteractionController.ATK_WAIT);
            return(false);
        }
        Debug.Log("No Aegis");

        StartCoroutine(AttackAnim(oppUnit, oppUnit.gameObject.transform.GetChild(0).GetComponent <Animator>(),
                                  oppUnit.gameObject.transform, diff, "-" + oppUnit.GetData().GetAttack().ToString(), useAttack));

        GetData().IsAttacked(oppUnit.GetData().GetAttack());
        if (GetData().IsDead())
        {
            if (oppUnit == this)
            {
                BoardProxy.instance.GiveLowestCharLvl(this);
            }
            else
            {
                oppUnit.AddLevel();
            }
            return(true);
        }
        return(false);
    }
Exemple #28
0
 public override void DidMove(UnitProxy unit, List <TileProxy> path)
 {
     if (path == null || path.Count == 0)
     {
         return;
     }
     path.RemoveAt(0);
     foreach (TileProxy tile in path)
     {
         tile.SetTurnsWall(value * 2, unit);
     }
 }
 void SetTeam(UnitProxy unit)
 {
     if (unit == null)
     {
         TeamPanel.SetActive(false);
     }
     else
     {
         TeamPanel.SetActive(true);
         // TODO: Change the outline banner here based on the faction
         TeamPanel.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = unit.GetData().GetTeam().ToString();
     }
 }
 void SwitchCharImages(UnitProxy unit)
 {
     if (unit == null)
     {
         ImagePanel.GetComponent <Image>().enabled = false;
     }
     else
     {
         Sprite img = unit.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite;
         ImagePanel.GetComponent <Image>().enabled = true;
         ImagePanel.GetComponent <Image>().sprite  = img;
     }
 }