Esempio n. 1
0
    // Use this for initialization
    public virtual void Start()
    {
        gameObject.layer = LayerManager.GetLayerTile();
        pos = transform.position;       //this has been assign right at grid generation, this line is for runtime grid generation

        if (!walkable)
        {
            renderer.material = matUnwalkable;
        }
        else
        {
            //cover system, wip
            if (GameControlTB.EnableCover())
            {
                if (Application.isPlaying)
                {
                    InitCover();
                }
            }
        }

        if (unit != null)
        {
            unit.occupiedTile = this;
        }
    }
Esempio n. 2
0
    void OnNextTurn()
    {
        countTillNextTurn -= 1;
        if (countTillNextTurn == 0)
        {
            turn -= 1;

            if (turn == 0)
            {
                GameControlTB.onNextTurnE -= OnNextTurn;
                UnitTB.onUnitDestroyedE   -= OnUnitDestroyed;
                delay = 0;
                DelayDestruct();
            }
            else
            {
                if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
                {
                    countTillNextTurn = UnitControl.activeFactionCount;
                }
                else
                {
                    countTillNextTurn = UnitControl.GetAllUnitCount();
                }
            }
        }
    }
Esempio n. 3
0
    public float GetCoverDefendBonusSquare(Vector3 posS)
    {
        if (cover.Count < 4)
        {
            Debug.Log("error getting cover, cover value not setup properly");
            return(0);
        }

        Vector2 dir       = new Vector2(posS.x - pos.x, posS.z - pos.z);
        float   angle     = Utility.VectorToAngle(dir);
        int     coverType = 0;

        if (angle == 45)
        {
            coverType = Mathf.Max((int)cover[0], (int)cover[1]);
        }
        else if (angle == 135)
        {
            coverType = Mathf.Max((int)cover[1], (int)cover[2]);
        }
        else if (angle == 225)
        {
            coverType = Mathf.Max((int)cover[2], (int)cover[3]);
        }
        else if (angle == 315)
        {
            coverType = Mathf.Max((int)cover[3], (int)cover[0]);
        }
        else if (angle > 45 && angle < 135)
        {
            coverType = (int)cover[1];
        }
        else if (angle > 135 && angle < 225)
        {
            coverType = (int)cover[2];
        }
        else if (angle > 225 && angle < 315)
        {
            coverType = (int)cover[3];
        }
        else if (angle >= 0 && angle < 45 || angle > 315 && angle < 360)
        {
            coverType = (int)cover[0];
        }
        else
        {
            Debug.Log("error getting cover, angle exceed 360");
        }

        if ((_CoverType)coverType == _CoverType.BlockHalf)
        {
            return(GameControlTB.GetCoverHalf());
        }
        else if ((_CoverType)coverType == _CoverType.BlockFull)
        {
            return(GameControlTB.GetCoverFull());
        }

        return(0);
    }
Esempio n. 4
0
    IEnumerator _OnNextTurn()
    {
        yield return(null);

        if (GameControlTB.GetTurnMode() == _TurnMode.SingleUnitPerTurn)
        {
            while (UnitControl.selectedUnit == null)
            {
                yield return(null);
            }
        }

        if (GameControlTB.IsPlayerTurn())
        {
            glow         = false;
            isPlayerTurn = true;
            BroadcastMessage("resetBool");
        }
        else
        {
            isPlayerTurn = false;
        }

        yield return(null);
    }
Esempio n. 5
0
 public void EndTurn()
 {
     if (!GameControlTB.battleEnded)
     {
         GameControlTB.OnEndTurn();
     }
 }
Esempio n. 6
0
    void PauseMenu()
    {
        GUIStyle style = new GUIStyle();

        style.alignment = TextAnchor.UpperCenter;

        int startX = Screen.width / 2 - 70;
        int startY = Screen.height / 2 - 200;
        int width = 120; int height = 25; int spaceY = 30;

        for (int i = 0; i < 3; i++)
        {
            GUI.Box(new Rect(startX, startY, 140, boxHeight), "");
        }

        style.fontSize = 20;      style.fontStyle = FontStyle.Bold; style.normal.textColor = UI.colorH;
        GUI.Label(new Rect(startX + 5, startY += 5, width, height), "Paused", style);

        startX += 10;     startY += 20;

        GUI.changed = false;

        GUIStyle style2 = new GUIStyle("Label");

        style2.alignment = TextAnchor.UpperCenter;

        //~ float musicVol=AudioManager.GetMusicVolume();
        //~ float sfxVol=AudioManager.GetSFXVolume();

        GUI.Label(new Rect(startX, startY += 35, width, 30), "Music Volume: " + ((musicVol * 100).ToString("f0")) + "%", style2);
        musicVol = GUI.HorizontalSlider(new Rect(startX, startY += 20, width, height), musicVol, 0.0F, 1.0F);
        GUI.Label(new Rect(startX, startY += 35, width, 30), "SFX Volume: " + ((sfxVol * 100).ToString("f0")) + "%", style2);
        sfxVol = GUI.HorizontalSlider(new Rect(startX, startY += 20, width, height), sfxVol, 0.0F, 1.0F);

        if (GUI.changed)
        {
            AudioManager.SetSFXVolume(sfxVol);
            AudioManager.SetMusicVolume(musicVol);
        }

        if (GUI.Button(new Rect(startX, startY += spaceY, width, height), "Resume", buttonStyleAlt))
        {
            TogglePause();
        }
        if (GUI.Button(new Rect(startX, startY += spaceY, width, height), "Restart", buttonStyleAlt))
        {
            Time.timeScale = 1;
            Application.LoadLevel(Application.loadedLevelName);
        }
        if (GUI.Button(new Rect(startX, startY += spaceY, width, height), "MainMenu", buttonStyleAlt))
        {
            Time.timeScale = 1;
            GameControlTB.LoadMainMenu();
        }


        startY   += spaceY + 5;
        boxHeight = startY - (Screen.height / 2 - 200);
    }
Esempio n. 7
0
    public static GameObject NewScene(_TileType tileType)
    {
        EditorApplication.NewScene();

        GameObject rootObj = new GameObject();

        rootObj.name = "TBTK";
        Transform rootT = rootObj.transform;

        GameObject obj = new GameObject(); obj.transform.parent = rootT;

        obj.name = "Units";

        obj      = new GameObject(); obj.transform.parent = rootT;
        obj.name = "GameControl";
        //obj.AddComponent<GameControlTB>();
        GameControlTB gameControl = obj.AddComponent <GameControlTB>();

        gameControl.playerFactionID.Add(0);

        obj      = new GameObject(); obj.transform.parent = rootT;
        obj.name = "GridManager";
        GridManager gridManager = obj.AddComponent <GridManager>();

        gridManager.playerPlacementAreas.Add(new Rect());

        GameObject hexTile = Resources.Load("ScenePrefab/HexTile", typeof(GameObject)) as GameObject;

        gridManager.hexTilePrefab = hexTile;
        GameObject SquareTile = Resources.Load("ScenePrefab/SquareTile", typeof(GameObject)) as GameObject;

        gridManager.squareTilePrefab = SquareTile;
        GenerateHexGrid(gridManager, tileType);

        obj      = new GameObject(); obj.transform.parent = rootT;
        obj.name = "AudioManager";
        obj.AddComponent <AudioManager>();
        //AudioManager HexGridManager=obj.AddComponent<AudioManager>();

        obj      = new GameObject(); obj.transform.parent = rootT;
        obj.name = "PerkManager";
        obj.AddComponent <PerkManagerTB>();
        //PerkManagerTB perkManager=obj.AddComponent<PerkManagerTB>();

        DestroyImmediate(Camera.main.gameObject);
        GameObject cam = Resources.Load("ScenePrefab/CameraControl", typeof(GameObject)) as GameObject;

        obj      = (GameObject)Instantiate(cam);       obj.transform.parent = rootT;
        obj.name = "CameraControl";
        //foreach(Transform child in obj.transform) child.localPosition=new Vector3(0, 20, -20);

        Camera.main.transform.position = new Vector3(0, 12, -12);
        Camera.main.transform.rotation = Quaternion.Euler(45, 0, 0);

        return(rootObj);
    }
Esempio n. 8
0
    void Awake()
    {
        LoadUnit();

        uc = (UnitControl)target;
        gc = uc.gameObject.GetComponent <GameControlTB>();
        if (gc != null)
        {
            InitPlayerUnitsList();
        }
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
#if ibox
        //get the faction id
        GameControlTB gctb       = GameObject.Find("GameControl").GetComponent <GameControlTB>();
        List <int>    factionIds = gctb.playerFactionID;
        p_factionId = factionIds[0];
        p_units     = UnitControl.GetAllUnitsOfFaction(p_factionId);
        totalUnits  = p_units.Count;
        idleUnits   = totalUnits;
#endif
    }
Esempio n. 10
0
    //onMouseDown for right click
    //function called when mouse cursor enter the area of the tile, default MonoBehaviour method
    //used to detech right mouse click on the tile
    void OnMouseOver()
    {
        if (GameControlTB.IsUnitPlacementState())
        {
            return;
        }

        if (Input.GetMouseButtonDown(1))
        {
            OnRightClick();
        }
    }
Esempio n. 11
0
    public void Show(int vicID)
    {
        vicFactionID = vicID;

        if (GameControlTB.playerFactionExisted)
        {
            if (GameControlTB.IsHotSeatMode())
            {
                if (GameControlTB.IsPlayerFaction(vicFactionID))
                {
                    outcomeTxt = "Victory!!";
                }
                else
                {
                    outcomeTxt = "Defeated...";
                }
            }
            //single player mode
            else
            {
                if (GameControlTB.IsPlayerFaction(vicFactionID))
                {
                    outcomeTxt = "Victory!!";
                }
                else
                {
                    outcomeTxt = "Defeated";
                }
            }
        }
        else
        {
            outcomeTxt = "Faction " + vicFactionID + " Won!!";
        }

        if (!GameControlTB.IsHotSeatMode() && GameControlTB.playerFactionExisted && GameControlTB.LoadMode() == _LoadMode.UsePersistantData)
        {
            int pointGain   = GameControlTB.instance.pointGain;
            int pointReward = GameControlTB.instance.winPointReward;
            if (!GameControlTB.IsPlayerFaction(vicFactionID))
            {
                pointReward = 0;
            }

            int killBonus = pointGain - pointReward;
            int total     = GlobalStatsTB.GetPlayerPoint();
            int initial   = total - pointGain;

            statsTxt = killBonus + "\n" + pointReward + "\n" + initial;
            pointTxt = total.ToString();
        }
    }
Esempio n. 12
0
    void Awake()
    {
        gc = (GameControlTB)target;
        uc = gc.gameObject.GetComponent <UnitControl>();


        InitLabel();

        if (gc.playerFactionID == null || gc.playerFactionID.Count == 0)
        {
            gc.playerFactionID = new List <int>();
            gc.playerFactionID.Add(0);
        }
    }
Esempio n. 13
0
    void Awake()
    {
        instance = this;

        turnID     = -1;
        turnIDLoop = 1;

        AbilityManagerTB.LoadUnitAbility();

        roundCounter = 0;
        battleEnded  = false;

        if (playerFactionID.Count == 0)
        {
            playerFactionID.Add(0);
        }
    }
Esempio n. 14
0
 //function called when tile is clicked in unit placement phase
 void PlaceUnit()
 {
     if (!openForPlacement)
     {
         GameControlTB.DisplayMessage("Invalid position");
         return;
     }
     if (unit == null)
     {
         if (placementID == UnitControl.GetPlayerUnitsBeingPlaced().factionID)
         {
             UnitControl.PlaceUnitAt(this);
         }
     }
     else if (unit.factionID == UnitControl.GetPlayerUnitsBeingPlaced().factionID)
     {
         UnitControl.RemoveUnit(unit);
     }
 }
Esempio n. 15
0
    void Awake()
    {
        LoadUnit();
        LoadObstacle();
        LoadCollectible();

        rotationLabel    = new string[7];
        rotationLabel[0] = "Random";
        rotationLabel[1] = "0";
        rotationLabel[2] = "60";
        rotationLabel[3] = "120";
        rotationLabel[4] = "180";
        rotationLabel[5] = "240";
        rotationLabel[6] = "300";

        int enumLength = Enum.GetValues(typeof(_TileType)).Length;

        tileTypeLabel = new string[enumLength];
        for (int i = 0; i < enumLength; i++)
        {
            tileTypeLabel[i] = ((_TileType)i).ToString();
        }

        tileTypeTooltip    = new string[enumLength];
        tileTypeTooltip[0] = "Use HexTile";
        tileTypeTooltip[1] = "Use SquareTile";


        enumLength      = Enum.GetValues(typeof(_SpawnQuota)).Length;
        spawnQuotaLabel = new string[enumLength];
        for (int i = 0; i < enumLength; i++)
        {
            spawnQuotaLabel[i] = ((_SpawnQuota)i).ToString();
        }

        spawnQuotaTooltip    = new string[enumLength];
        spawnQuotaTooltip[0] = "Spawn a set number of unit for the area\nEach prefab have a spawn limit";
        spawnQuotaTooltip[1] = "Spawn a varied number of unit for the area based on the point budget available";

        gc = (GameControlTB)FindObjectOfType(typeof(GameControlTB));
    }
Esempio n. 16
0
    void OnGameOver(int vicFactionID)
    {
        //if(victory) PlayGameWonSound();
        //else PlayGameLostSound();

        if (GameControlTB.playerFactionExisted)
        {
            if (GameControlTB.IsPlayerFaction(vicFactionID))
            {
                PlayGameWonSound();
            }
            else
            {
                PlayGameLostSound();
            }
        }
        else
        {
            PlayGameWonSound();
        }
    }
Esempio n. 17
0
    //AI routine to move a single unit
    IEnumerator _AIRoutineSingleUnit(UnitTB unit)
    {
        while (GameControlTB.IsActionInProgress())
        {
            yield return(null);
        }
        yield return(new WaitForSeconds(1f));

        unitInAction = true;
        instance.StartCoroutine(instance._MoveUnit(unit));

        //wait a frame for the unit to start moving, set the inAction flag, etc..
        yield return(null);

        while (unit.InAction() || GameControlTB.IsActionInProgress() || unitInAction)
        {
            yield return(null);
        }

        GameControlTB.OnEndTurn();
    }
Esempio n. 18
0
    void OnEndTurnButton()
    {
        if (GameControlTB.IsActionInProgress())
        {
            return;
        }

        if (GameControlTB.GetTurnMode() != _TurnMode.SingleUnitPerTurn)
        {
            if (GameControlTB.GetMoveOrder() == _MoveOrder.Free)
            {
                if (UnitControl.selectedUnit != null)
                {
                    UnitControl.selectedUnit.moved    = true;
                    UnitControl.selectedUnit.attacked = true;
                    UnitControl.MoveUnit(UnitControl.selectedUnit);
                }
            }
        }

        GameControlTB.OnEndTurn();
    }
Esempio n. 19
0
    public void Trigger(UnitTB unit)
    {
        foreach (EffectAttr effectAttr in effect.effectAttrs)
        {
            if (effectAttr.type == _EffectAttrType.PointGain)
            {
                GameControlTB.GainPoint((int)effectAttr.value);
            }
        }

        if (enableAOE && aoeRange > 1)
        {
            List <Tile> list = GridManager.GetTilesWithinRange(occupiedTile, aoeRange);
            foreach (Tile tile in list)
            {
                if (tile.unit != null)
                {
                    tile.unit.ApplyCollectibleEffect(effect);
                }
            }
        }
        else
        {
            unit.ApplyCollectibleEffect(effect);
        }


        if (triggerEffect != null)
        {
            Instantiate(triggerEffect, occupiedTile.pos, Quaternion.identity);
        }

        if (triggerAudio != null)
        {
            AudioManager.PlaySound(triggerAudio, thisT.position);
        }

        Destroy(thisObj);
    }
Esempio n. 20
0
    //code execution for when a mouse enter a tile or when a touch first tap on a tile
    public void OnTouchMouseEnter()
    {
                #if !UNITY_IPHONE && !UNITY_ANDROID
        if (GameControlTB.IsCursorOnUI(Input.mousePosition))
        {
            return;
        }
        //if(GameControlTB.IsObjectOnUI(pos)) return;
                #endif

        if (!walkable && !GridManager.IsInTargetTileSelectMode())
        {
            return;
        }

        GridManager.OnHoverEnter(this);

        if (unit != null)
        {
            UnitControl.hoveredUnit = unit;
        }
    }
Esempio n. 21
0
 void OnEnable()
 {
     if (mode == _DelayMode.RealTime)
     {
         DelayDestruct();
     }
     else if (mode == _DelayMode.Round)
     {
         GameControlTB.onNewRoundE += OnNewRound;
     }
     else if (mode == _DelayMode.Turn)
     {
         GameControlTB.onNextTurnE += OnNextTurn;
         UnitTB.onUnitDestroyedE   += OnUnitDestroyed;
         if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
         {
             countTillNextTurn = UnitControl.activeFactionCount;
         }
         else
         {
             countTillNextTurn = UnitControl.GetAllUnitCount();
         }
     }
 }
Esempio n. 22
0
    //buffer function for select when the selection is initiated by player, check turn mode condition before proceed
    public void ManualSelect()
    {
        //if not in target select phase for unitAbility
        if (!GridManager.IsInTargetTileSelectMode())
        {
            if (!GameControlTB.AllowUnitSwitching())
            {
                //Debug.Log("unit swtiching is lock");
                return;
            }

            _MoveOrder moveOrder = GameControlTB.GetMoveOrder();

            //if turn mode and turnOrder doesnt not support unit switching, return
            if (moveOrder != _MoveOrder.Free)
            {
                return;
            }

            _TurnMode turnMode = GameControlTB.GetTurnMode();
            if (turnMode == _TurnMode.FactionSingleUnitPerTurnAll)
            {
                if (unit.MovedForTheRound())
                {
                    Debug.Log("unit has been moved");
                    return;
                }
            }
            else if (turnMode == _TurnMode.SingleUnitPerTurn)
            {
                //Debug.Log("turn mode not allow switching");
                return;
            }
        }
        Select();
    }
Esempio n. 23
0
    void Awake()
    {
        LoadUnit();

        uc=(UnitControl)target;
        gc=uc.gameObject.GetComponent<GameControlTB>();
        if(gc!=null) InitPlayerUnitsList();
    }
Esempio n. 24
0
    public float GetCoverDefendBonusHex(Vector3 posS)
    {
        if (cover.Count < 6)
        {
            Debug.Log("error getting cover, cover value not setup properly");
            return(0);
        }

        Vector2 dir       = new Vector2(posS.x - pos.x, posS.z - pos.z);
        float   angle     = Utility.VectorToAngle(dir);
        int     coverType = 0;

        if (angle == 0)
        {
            coverType = Mathf.Max((int)cover[0], (int)cover[5]);
        }
        else if (angle == 60)
        {
            coverType = Mathf.Max((int)cover[0], (int)cover[1]);
        }
        else if (angle == 120)
        {
            coverType = Mathf.Max((int)cover[1], (int)cover[2]);
        }
        else if (angle == 180)
        {
            coverType = Mathf.Max((int)cover[2], (int)cover[3]);
        }
        else if (angle == 240)
        {
            coverType = Mathf.Max((int)cover[3], (int)cover[4]);
        }
        else if (angle == 300)
        {
            coverType = Mathf.Max((int)cover[4], (int)cover[5]);
        }
        else if (angle > 0 && angle < 60)
        {
            coverType = (int)cover[0];
        }
        else if (angle > 60 && angle < 120)
        {
            coverType = (int)cover[1];
        }
        else if (angle > 120 && angle < 180)
        {
            coverType = (int)cover[2];
        }
        else if (angle > 180 && angle < 240)
        {
            coverType = (int)cover[3];
        }
        else if (angle > 240 && angle < 300)
        {
            coverType = (int)cover[4];
        }
        else if (angle > 300 && angle < 360)
        {
            coverType = (int)cover[5];
        }
        else
        {
            Debug.Log("error getting cover, angle exceed 360");
        }

        if ((_CoverType)coverType == _CoverType.BlockHalf)
        {
            return(GameControlTB.GetCoverHalf());
        }
        else if ((_CoverType)coverType == _CoverType.BlockFull)
        {
            return(GameControlTB.GetCoverFull());
        }

        return(0);
    }
Esempio n. 25
0
    void Awake()
    {
        gc=(GameControlTB)target;
        uc=gc.gameObject.GetComponent<UnitControl>();

        InitLabel();

        if(gc.playerFactionID==null || gc.playerFactionID.Count==0){
            gc.playerFactionID=new List<int>();
            gc.playerFactionID.Add(0);
        }
    }
Esempio n. 26
0
    void OnNextTurn()
    {
        for (int i = 0; i < activeUnitAbilityEffectList.Count; i++)
        {
            UnitAbility uAB = activeUnitAbilityEffectList[i];
            uAB.countTillNextTurn -= 1;
            if (uAB.countTillNextTurn == 0)
            {
                if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
                {
                    uAB.countTillNextTurn = UnitControl.activeFactionCount;
                }
                else
                {
                    uAB.countTillNextTurn = UnitControl.GetAllUnitCount();
                }

                bool flag = CalulateEffect(uAB);

                //false means no more effect active for the ability, remove the ability
                if (!flag)
                {
                    activeUnitAbilityEffectList.RemoveAt(i);
                    i -= 1;

                    //if not more ability, stop listening to any event
                    if (activeUnitAbilityEffectList.Count == 0)
                    {
                        UnsubscribeEvent();
                    }
                }
            }
        }

        //apply the effect, this is placed here so it only runs when there are active effect
        countTillNextTurn -= 1;
        if (countTillNextTurn == 0)
        {
            //apply the effect on unit
            if (unit != null)
            {
                if (HPGainModifier > 0)
                {
                    unit.ApplyHeal(HPGainModifier);
                }
                else if (HPGainModifier < 0)
                {
                    unit.ApplyDamage(HPGainModifier);
                }
                if (APGainModifier != 0)
                {
                    unit.GainAP(APGainModifier);
                }
            }

            if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
            {
                countTillNextTurn = UnitControl.activeFactionCount;
            }
            else
            {
                countTillNextTurn = UnitControl.GetAllUnitCount();
            }
        }
    }
Esempio n. 27
0
    void DrawHoverInfo()
    {
        UnitTB selectedUnit = UnitControl.selectedUnit;

#if hoverHP
        if (tileHovered.unit != null)
        {
            //draw hp and AP for unit
            UnitTB hUnit = tileHovered.unit;

            Camera  camA       = CameraControl.GetActiveCamera();
            Vector3 screenPosA = camA.WorldToScreenPoint(hUnit.thisT.position);
            screenPosA.y = Screen.height - screenPosA.y;

            int startPosX = (int)(screenPosA.x - 40 / 2 + 7);
            int startPosY = (int)screenPosA.y + 5;

            styleA.fontSize = 20;     styleA.normal.textColor = UI.colorH;      styleA.alignment = TextAnchor.UpperCenter;
            GUI.Box(new Rect(startPosX - x_offset - 25, startPosY + y_offset, 140, 140), "");

            GUI.Label(new Rect(startPosX - x_offset - 25, startPosY + y_offset, 140, 140), "\n HP:" + hUnit.HP + "/" + hUnit.GetFullHP() + "\n AP:" + hUnit.AP + "/" + hUnit.GetFullAP() + "\n Moves:" + hUnit.moveRemain + "\n Attacks:" + hUnit.attackRemain, styleA);
        }
#endif
        if (tileHovered.attackableToSelected)
        {
            UnitTB unit = tileHovered.unit;

            int    dmgMin = 0, dmgMax = 0;
            string hit = "", crit = "";

            int dist = GridManager.Distance(tileHovered, selectedUnit.occupiedTile);

            int   armorType   = unit.armorType;
            int   damageType  = selectedUnit.damageType;
            float dmgModifier = DamageTable.GetModifier(armorType, damageType);

            if (dist == 1 && selectedUnit.attackMode != _AttackMode.Range)
            {
                dmgMin = (int)((float)selectedUnit.GetMeleeDamageMin() * dmgModifier);
                dmgMax = (int)((float)selectedUnit.GetMeleeDamageMax() * dmgModifier);

                hit  = (selectedUnit.GetTotalHitChanceMelee(unit) * 100).ToString("f0") + "%";
                crit = (selectedUnit.GetTotalCritChanceMelee(unit) * 100).ToString("f0") + "%";
            }
            else
            {
                dmgMin = (int)((float)selectedUnit.GetRangeDamageMin() * dmgModifier);
                dmgMax = (int)((float)selectedUnit.GetRangeDamageMax() * dmgModifier);

                hit  = (selectedUnit.GetTotalHitChanceRange(unit) * 100).ToString("f0") + "%";
                crit = (selectedUnit.GetTotalCritChanceRange(unit) * 100).ToString("f0") + "%";
            }

            string text = "";
            text += hit + "chance to hit\n";
            text += "Damage: " + dmgMin + "-" + dmgMax + "\n\n";
            if (crit != "0%")
            {
                text += "Critical Chance: " + crit;
            }


            bool counter = false;
            if (GameControlTB.IsCounterAttackEnabled())
            {
                if (dist >= unit.GetAttackRangeMin() && dist <= unit.GetAttackRangeMax() && unit.counterAttackRemain > 0)
                {
                    counter = true;
                }
            }

            int cost = 0;
            if (GameControlTB.AttackAPCostRule() == _AttackAPCostRule.PerAttack)
            {
                cost = selectedUnit.APCostAttack;
            }

            GUIStyle style = new GUIStyle();
            style.fontStyle = FontStyle.Bold;

#if mousePos
            int width    = 500;
            int w_offset = 50;
            int height   = 160;
            int h_offset = 20;


            //get pos X and Y once every second to prevent flicker
            getMousePos();

            /*for(int i=0; i<3; i++) GUI.Box(new Rect(posX-(width+w_offset)/2, posY-230, width+w_offset, height), "");
             *
             * style.fontSize=20;	style.normal.textColor=UI.colorH;	style.alignment=TextAnchor.UpperCenter;
             * GUI.Label(new Rect(posX-width/2, posY-240, width, height), ability.name, style);
             *
             * style.fontSize=16;	style.normal.textColor=UI.colorH;	style.alignment=TextAnchor.UpperRight;
             * GUI.Label(new Rect(posX-width/2-5, posY-240, width, height), ability.cost+"AP", style);
             *
             * style.fontSize=16;	style.normal.textColor=UI.colorN;	style.alignment=TextAnchor.UpperCenter;	style.wordWrap=true;
             * GUI.Label(new Rect(posX-width/2, posY-190, width, height), ability.desp, style);
             *
             * GUI.color=Color.white;*/

            //for(int i=0; i<3; i++) GUI.Box(new Rect(posX-(width +w_offset)/2, posY, width+w_offset, height), "");


            GUI.Box(new Rect(posX - (width / 2) / 2, Screen.height - posY + 40, width / 2, height - 20), "");       // to remove flicker comment out this line

            style.fontSize = 20;      style.normal.textColor = UI.colorH;       style.alignment = TextAnchor.UpperCenter;
            GUI.Label(new Rect(posX - (width) / 2, Screen.height - posY + 40 + h_offset, width, height), "Attack", style);


            if (cost > 0)
            {
                style.fontSize = 16;      style.normal.textColor = UI.colorH;       style.alignment = TextAnchor.UpperRight;
                GUI.Label(new Rect(posX - width / 2 - 5, Screen.height - posY + 50 + h_offset, width, height), cost + "AP", style);
            }

            //reposition to be at location of mouse
            style.fontSize = 16;      style.normal.textColor = UI.colorN;       style.alignment = TextAnchor.UpperCenter; style.wordWrap = true;
            GUI.Label(new Rect(posX - width / 2, Screen.height - posY + 60 + h_offset, width, height), text, style);
            if (counter)
            {
                style.fontSize = 14;      style.normal.textColor = UI.colorH;       style.wordWrap = false;
                GUI.Label(new Rect(posX - width / 2, Screen.height - posY + 40 + h_offset, width, height), "Target will counter attack", style);
            }
#else
            int width  = 500;
            int height = 160;
            for (int i = 0; i < 3; i++)
            {
                GUI.Box(new Rect(Screen.width / 2 - width / 2, Screen.height - 230, width, height), "");
            }

            style.fontSize = 20;      style.normal.textColor = UI.colorH;       style.alignment = TextAnchor.UpperCenter;
            GUI.Label(new Rect(Screen.width / 2 - width / 2, Screen.height - 240, width, height), "Attack", style);

            if (cost > 0)
            {
                style.fontSize = 16;      style.normal.textColor = UI.colorH;       style.alignment = TextAnchor.UpperRight;
                GUI.Label(new Rect(Screen.width / 2 - width / 2 - 5, Screen.height - 220, width, height), cost + "AP", style);
            }

            //reposition to be at location of mouse
            style.fontSize = 16;      style.normal.textColor = UI.colorN;       style.alignment = TextAnchor.UpperCenter; style.wordWrap = true;
            GUI.Label(new Rect(Screen.width / 2 - width / 2, Screen.height - 190, width, height), text, style);
            if (counter)
            {
                style.fontSize = 14;      style.normal.textColor = UI.colorH;       style.wordWrap = false;
                GUI.Label(new Rect(Screen.width / 2 - width / 2, Screen.height - 120, width, height), "Target will counter attack", style);
            }
#endif

            GUI.color = Color.white;
        }
        else
        {
            if (tileHovered.walkableToSelected && selectedUnit != null)
            {
                //Vector3 screenPos = cam.WorldToScreenPoint(tileHovered.pos);
                //hoverObject.transform.localPosition=screenPos+new Vector3(-40, 40, 0);

                List <Vector3> list = AStar.SearchWalkablePos(tileHovered, selectedUnit.occupiedTile);
                int            dist = list.Count;
                string         text = "Move: " + (dist * selectedUnit.APCostMove) + "AP";
                //string text="Move: "+Random.Range(0, 9999)+"AP";
                GUIContent cont = new GUIContent(text);

                GUI.color = Color.white;
                GUIStyle style = new GUIStyle();
                style.fontStyle        = FontStyle.Bold;
                style.fontSize         = 16;
                style.normal.textColor = UI.colorN;
                style.alignment        = TextAnchor.LowerRight;

                Camera  cam       = CameraControl.GetActiveCamera();
                Vector3 screenPos = cam.WorldToScreenPoint(tileHovered.pos);
                screenPos.y = Screen.height - screenPos.y;

                float widthMin = 0; float widthMax = 0;
                style.CalcMinMaxWidth(cont, out widthMin, out widthMax);
#if ibox
#else
                GUI.Box(new Rect(screenPos.x - widthMax - 50, screenPos.y - 50, widthMax + 25, 22), "");
                GUI.Label(new Rect(screenPos.x - widthMax - 50, screenPos.y - 50, widthMax + 25 - 4, 20), text, style);
#endif
            }
        }
    }
Esempio n. 28
0
    void OnGUI()
    {
        //if(!battleStarted) return;
                #if customGui
        GUI.skin = Resources.Load("Skins/Fantasy-Colorable") as GUISkin;
                #endif

        DrawOverlay();

        List <UnitTB> unitList = UnitControl.GetAllUnit();

        int length = 40;
        int height = 3;

        for (int i = 0; i < unitList.Count; i++)
        {
            UnitTB unit = unitList[i];

            if (GameControlTB.EnableFogOfWar())
            {
                if (!unit.IsVisibleToPlayer())
                {
                    continue;
                }
            }



#if hoverInfo
            Camera  cam       = CameraControl.GetActiveCamera();
            Vector3 screenPos = cam.WorldToScreenPoint(unitList[i].thisT.position);
            screenPos.y = Screen.height - screenPos.y;

            int startPosX = (int)(screenPos.x - length / 2 + 7);
            int startPosY = (int)screenPos.y + 5;

            float hpRatio = (float)unit.HP / (float)unit.GetFullHP() * length;
            float apRatio = (float)unit.AP / (float)unit.GetFullAP() * length;


            GUIStyle style = new GUIStyle();
            style.fontStyle = FontStyle.Bold;

            style.fontSize = 20;



            style.fontSize = 20;      style.normal.textColor = UI.colorH;       style.alignment = TextAnchor.UpperCenter;
            GUI.Label(new Rect(startPosX - x_offset, startPosY + y_offset, 90, 90), "\n HP:" + unit.HP + "/" + unit.GetFullHP() + "\n AP:" + unit.AP + "/" + unit.GetFullAP(), style);


            GUI.color = Color.white;
            //draw the hp and AP
            //GUI.Box(new Rect(startPosX, startPosY-20, 200, 200), UI.texBar);
#else
            Camera  cam       = CameraControl.GetActiveCamera();
            Vector3 screenPos = cam.WorldToScreenPoint(unitList[i].thisT.position);
            screenPos.y = Screen.height - screenPos.y;

            int startPosX = (int)(screenPos.x - length / 2 + 7);
            int startPosY = (int)screenPos.y + 5;

            float hpRatio = (float)unit.HP / (float)unit.GetFullHP() * length;
            float apRatio = (float)unit.AP / (float)unit.GetFullAP() * length;

            GUI.color = new Color(.5f, .5f, .5f, 1);
            GUI.DrawTexture(new Rect(startPosX - 1, startPosY - 1, length + 2, 2 * height + 2), UI.texBar);
            GUI.color = Color.green;
            //TODO: Add the numbers for AP and HP here, we have startpos X and Y, and other values
            //are calculated elsewhere
            GUI.DrawTexture(new Rect(startPosX, startPosY, hpRatio, height), UI.texBar);
            //GUI.Label(new Rect(screenPos.x, screenPos.y, 500, 500), "5555");
            GUI.color = new Color(0f, 1f, 1f, 1);
            GUI.DrawTexture(new Rect(startPosX, startPosY + height, apRatio, height), UI.texBar);
            Texture fIcon = UnitControl.GetFactionIcon(unitList[i].factionID);
            if (fIcon != null)
            {
                fIcon = UI.texBar;
            }

            GUI.color = Color.white;
            GUI.DrawTexture(new Rect(startPosX - 15, startPosY - 5, 15, 15), UI.texBar);


            GUI.color = UnitControl.GetFactionColor(unit.factionID);
            GUI.DrawTexture(new Rect(startPosX - 14, startPosY - 4, 13, 13), UI.texBar);

            GUI.color = Color.white;
#endif
        }

        if (tileHovered != null)
        {
            DrawHoverInfo();
        }
        ///Draw text box with selected unit health and AP
                #if ibox
        /*
         *
         * void ShowTooltip(UnitAbility ability){
         * GUIStyle style=new GUIStyle();
         * style.fontStyle=FontStyle.Bold;
         *
         * int width=500;
         * int height=160;
         *
         *
         * for(int i=0; i<3; i++) GUI.Box(new Rect(Screen.width/2-width/2, Screen.height-230, width, height), "");
         *
         * style.fontSize=20;	style.normal.textColor=UI.colorH;	style.alignment=TextAnchor.UpperCenter;
         * GUI.Label(new Rect(Screen.width/2-width/2, Screen.height-220, width, height), ability.name, style);
         *
         * style.fontSize=16;	style.normal.textColor=UI.colorH;	style.alignment=TextAnchor.UpperRight;
         * GUI.Label(new Rect(Screen.width/2-width/2-5, Screen.height-220, width, height), ability.cost+"AP", style);
         *
         * style.fontSize=16;	style.normal.textColor=UI.colorN;	style.alignment=TextAnchor.UpperCenter;	style.wordWrap=true;
         * GUI.Label(new Rect(Screen.width/2-width/2, Screen.height-190, width, height), ability.desp, style);
         *
         * GUI.color=Color.white;
         * }
         * */

        if (UnitControl.selectedUnit != null)         //only perform this calculation once every second
        //get the selected unit
        {
            UnitTB selectedUnit = UnitControl.selectedUnit;
            string name         = selectedUnit.unitName;


            Camera  cam       = CameraControl.GetActiveCamera();
            Vector3 screenPos = cam.WorldToScreenPoint(UnitControl.selectedUnit.thisT.position);
            screenPos.y = Screen.height - screenPos.y;

            int startPosX = (int)(screenPos.x - length / 2 + 7);
            int startPosY = (int)screenPos.y + 5;



            styleA.fontSize = 20;



            styleA.fontSize = 20;     styleA.normal.textColor = UI.colorH;      styleA.alignment = TextAnchor.UpperCenter;


            GUI.Box(new Rect(startPosX - x_offset - 25, startPosY + y_offset, 140, 140), "");

            GUI.Label(new Rect(startPosX - x_offset - 25, startPosY + y_offset, 140, 140), "\n HP:" + UnitControl.selectedUnit.HP + "/" + UnitControl.selectedUnit.GetFullHP() + "\n AP:" + UnitControl.selectedUnit.AP + "/" + UnitControl.selectedUnit.GetFullAP() + "\n Moves:" + UnitControl.selectedUnit.moveRemain + "\n Attacks:" + UnitControl.selectedUnit.attackRemain, styleA);


            GUI.color = Color.white;


            GUIStyle style = new GUIStyle();
            style.fontStyle = FontStyle.Bold;

            int w = w_width;
            int h = w_height;

            style.fontSize = 20;

            style.fontSize = 20;      style.normal.textColor = UI.colorH;       style.alignment = TextAnchor.UpperCenter;
#if window
            //Color c = GUI.color;
            //GUI.color = Color.red;
            //windowRect0 = GUI.Window(0,windowRect0,DoMyWindow, "Green Window");
            //GUI.color = c;

                        #if devIbox
            GUI.Box(new Rect(Screen.width / 2 - 750 / 2, -80, 750, h), "");
            GUI.Label(new Rect(Screen.width / 2 - w / 2, 0, w, h), name + " HP:" + selectedUnit.HP + " AP:" + selectedUnit.AP + " Remaining Moves:" + selectedUnit.moveRemain + " Remaining Attacks: " + selectedUnit.attackRemain, style);
#endif
#if mo
            if (timeSinceCheck > .25)
            {
                //TODO: This method is not efficient, change it later
                //get the unit position
                //get the gameObject first
                GameObject g = selectedUnit.thisObj;
                //get the camera
                Camera  c         = GameObject.Find("MainCamera").GetComponent <Camera>();
                Vector3 screenPos = camera.WorldToScreenPoint(g.transform.position);

                Debug.Log(screenPos.x + " : " + screenPos.y);
                //put a simplified version of the ibox at the unit position
                GUI.Box(new Rect(screenPos.x, screenPos.y, 100, 30), "");
                GUI.Label(new Rect(screenPos.x, screenPos.y, 100, 30), " HP:" + selectedUnit.HP + " AP:" + selectedUnit.AP, style);
            }
#endif

            //print unit information
            //GUI.Label(new Rect(Screen.width/2-250, 0, 500, 20), name+" HP:"+selectedUnit.HP+" AP:"+selectedUnit.AP+" Remaining Moves:"+selectedUnit.moveRemain +" Remaining Attacks: " +selectedUnit.attackRemain);
            if (lastCheck >= waitTime)
            {
                lastCheck = 0;
                idleUnits = totalUnits;
                //get idle units
                //get an array of their units
                p_units = UnitControl.GetAllUnitsOfFaction(p_factionId);
                //loop through the array
                foreach (UnitTB unit in p_units)
                {
                    if (unit.AreAllActionsCompleted())
                    {
                        /*GameObject g = unit.thisObj;
                         * Renderer r = g.renderer;
                         * r.material.color = Color.grey;*/
                        idleUnits--;
                    }
                    else if (false)                     //TODO: if the unit has no more moves, cannot use an ability, and cannot attack anyone

                    {
                    }
                    //if a unit has moves left, or attacks left, increment idle units
                }
            }
            else
            {
                lastCheck += Time.deltaTime;
            }
            //print idle information
            if (idleUnits == 0)
            {
                //TODO: change coords to put it right above next turn button
                //GUI.Label(new Rect(Screen.width/2-w/2, 25, w, h), "All units have exhausted their moves, hit the next turn.", style);
                //only toggle glow once per turn
                if (!messageSent)
                {
                    BroadcastMessage("toggleGlow");
                    messageSent = true;
                }
                //GUI.Label (new Rect(Screen.width/2-250, 15, 500, 20), "All units have exhausted their moves, hit the next turn.");
            }
            else
            {
                BroadcastMessage("turnoffGlow");
                GUI.Label(new Rect(Screen.width - 100, Screen.height - 65 - 20, 60, 60), idleUnits + "/" + totalUnits + " idle units", style);

                //GUI.Label (new Rect(Screen.width/2-250, 15, 500, 20),idleUnits + "/"+ totalUnits + " units still have available actions.");
            }
#else
            GUI.Box(new Rect(Screen.width / 2 - 750 / 2, -80, 750, h), "");
            GUI.Label(new Rect(Screen.width / 2 - w / 2, 0, w, h), name + " HP:" + selectedUnit.HP + " AP:" + selectedUnit.AP + " Remaining Moves:" + selectedUnit.moveRemain + " Remaining Attacks: " + selectedUnit.attackRemain, style);

            //print unit information
            //GUI.Label(new Rect(Screen.width/2-250, 0, 500, 20), name+" HP:"+selectedUnit.HP+" AP:"+selectedUnit.AP+" Remaining Moves:"+selectedUnit.moveRemain +" Remaining Attacks: " +selectedUnit.attackRemain);
            if (lastCheck >= waitTime)
            {
                lastCheck = 0;
                idleUnits = totalUnits;
                //get idle units
                //get an array of their units
                p_units = UnitControl.GetAllUnitsOfFaction(p_factionId);
                //loop through the array
                foreach (UnitTB unit in p_units)
                {
                    if (unit.AreAllActionsCompleted())
                    {
                        idleUnits--;
                    }
                    else if (false)                     //TODO: if the unit has no more moves, cannot use an ability, and cannot attack anyone

                    {
                    }
                    //if a unit has moves left, or attacks left, increment idle units
                }
            }
            else
            {
                lastCheck += Time.deltaTime;
            }
            //print idle information
            if (idleUnits == 0)
            {
                GUI.Label(new Rect(Screen.width / 2 - w / 2, 25, w, h), "All units have exhausted their moves, hit the next turn.", style);
                //GUI.Label (new Rect(Screen.width/2-250, 15, 500, 20), "All units have exhausted their moves, hit the next turn.");
            }
            else
            {
                GUI.Label(new Rect(Screen.width / 2 - w / 2, 25, w, h), idleUnits + "/" + totalUnits + " units still have available actions.", style);

                //GUI.Label (new Rect(Screen.width/2-250, 15, 500, 20),idleUnits + "/"+ totalUnits + " units still have available actions.");
            }
#endif
        }
                #endif
    }
Esempio n. 29
0
    public override void OnInspectorGUI()
    {
        gc = (GameControlTB)target;

        //DrawDefaultInspector();

        EditorGUILayout.Space();
        EditorGUILayout.Space();


        int turnMode = (int)gc.turnMode;

        cont  = new GUIContent("Turn Mode:", "Turn mode to be used in this scene");
        contL = new GUIContent[turnModeLabel.Length];
        for (int i = 0; i < contL.Length; i++)
        {
            contL[i] = new GUIContent(turnModeLabel[i], turnModeTooltip[i]);
        }
        turnMode    = EditorGUILayout.IntPopup(cont, turnMode, contL, intVal);
        gc.turnMode = (_TurnMode)turnMode;


        if (turnMode <= 2)
        {
            int moveOrder = (int)gc.moveOrder;
            cont  = new GUIContent("Move Order:", "Unit move order to be used in this scene");
            contL = new GUIContent[moveOrderLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(moveOrderLabel[i], moveOrderTooltip[i]);
            }
            moveOrder    = EditorGUILayout.IntPopup(cont, moveOrder, contL, intVal);
            gc.moveOrder = (_MoveOrder)moveOrder;
        }


        int loadMode = (int)gc.loadMode;

        cont  = new GUIContent("Data Load Mode:", "Data loading mode to be used in this scene");
        contL = new GUIContent[loadModeLabel.Length];
        for (int i = 0; i < contL.Length; i++)
        {
            contL[i] = new GUIContent(loadModeLabel[i], loadModeTooltip[i]);
        }
        loadMode    = EditorGUILayout.IntPopup(cont, loadMode, contL, intVal);
        gc.loadMode = (_LoadMode)loadMode;


        cont = new GUIContent("Enable Perk Menu:", "check to enable PerkMenu to be brought out in the scene");
        EditorGUILayout.BeginHorizontal("");
        //EditorGUILayout.LabelField(cont);
        gc.enablePerkMenu = EditorGUILayout.Toggle(cont, gc.enablePerkMenu);
        EditorGUILayout.EndHorizontal();



        //cont=new GUIContent("PlayerFactionID:", "Numerial ID to identify player's units\nAny unit with similar unitID will be able to control by player\nif no unit with similar unitID is in the scene, the whole game will be run by AI");
        //gc.playerFactionID[0]=EditorGUILayout.IntField(cont, gc.playerFactionID[0]);

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        cont = new GUIContent("HotSeat Mode:", "check to enable local hot seat multiplayer\nenable multiple player faction");
        EditorGUILayout.BeginHorizontal("");
        //EditorGUILayout.LabelField(cont);
        gc.hotseat = EditorGUILayout.Toggle(cont, gc.hotseat);
        EditorGUILayout.EndHorizontal();


        if (gc.hotseat)
        {
            gc.enableFogOfWar = false;

            if (gc.playerFactionID.Count == 1)
            {
                int ID    = gc.playerFactionID[0];
                int newID = 0;
                if (ID == 0)
                {
                    newID = 1;
                }

                gc.playerFactionID.Add(newID);
                uc.playerUnits.Add(new PlayerUnits(newID));
            }

            for (int i = 0; i < gc.playerFactionID.Count; i++)
            {
                EditorGUILayout.BeginHorizontal("");
                cont = new GUIContent("PlayerFactionID - " + i + ":", "Numerial ID to identify player's units\nAny unit with similar unitID will be able to control by player\nif no unit with similar unitID is in the scene, the whole game will be run by AI");
                int ID = gc.playerFactionID[i];
                ID = EditorGUILayout.IntField(cont, ID, GUILayout.MaxHeight(16));
                if (!gc.playerFactionID.Contains(ID))
                {
                    gc.playerFactionID[i]       = ID;
                    uc.playerUnits[i].factionID = ID;
                }
                if (GUILayout.Button("Remove", GUILayout.MaxHeight(16)))
                {
                    if (gc.playerFactionID.Count > 2)
                    {
                        gc.playerFactionID.RemoveAt(i);
                        uc.playerUnits.RemoveAt(i);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            if (GUILayout.Button("Add more player", GUILayout.MaxHeight(16)))
            {
                int newID = 0;
                while (gc.playerFactionID.Contains(newID))
                {
                    newID += 1;
                }
                gc.playerFactionID.Add(newID);
                uc.playerUnits.Add(new PlayerUnits(newID));
            }
        }
        else
        {
            if (gc.playerFactionID.Count > 1)
            {
                //int ID=gc.playerFactionID[0];
                //gc.playerFactionID=new List<int>();
                //gc.playerFactionID.Add(ID);

                for (int i = 0; i < gc.playerFactionID.Count - 1; i++)
                {
                    gc.playerFactionID.RemoveAt(1);
                    uc.playerUnits.RemoveAt(1);
                }
            }

            cont = new GUIContent("PlayerFactionID:", "Numerial ID to identify player's units\nAny unit with similar unitID will be able to control by player\nif no unit with similar unitID is in the scene, the whole game will be run by AI");
            gc.playerFactionID[0]       = EditorGUILayout.IntField(cont, gc.playerFactionID[0]);
            uc.playerUnits[0].factionID = gc.playerFactionID[0];
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();


        int moveRule = (int)gc.movementAPCostRule;

        cont  = new GUIContent("Movement AP Rule:", "The AP cost of unit's movement");
        contL = new GUIContent[moveAPRuleLabel.Length];
        for (int i = 0; i < contL.Length; i++)
        {
            contL[i] = new GUIContent(moveAPRuleLabel[i], moveAPRuleTooltip[i]);
        }
        moveRule = EditorGUILayout.IntPopup(cont, moveRule, contL, intVal, GUILayout.ExpandWidth(true));
        gc.movementAPCostRule = (_MovementAPCostRule)moveRule;

        /*
         * if(gc.movementAPCostRule==_MovementAPCostRule.PerMove){
         *      cont=new GUIContent("AP Cost Per Move:", "AP cost for unit to move");
         *      gc.movementAPCost=EditorGUILayout.IntField(cont, gc.movementAPCost);
         * }
         * else if(gc.movementAPCostRule==_MovementAPCostRule.PerTile){
         *      cont=new GUIContent("AP Cost Per Move:", "AP cost for unit to move across each tile");
         *      gc.movementAPCost=EditorGUILayout.IntField(cont, gc.movementAPCost);
         * }
         */

        int attackRule = (int)gc.attackAPCostRule;

        cont  = new GUIContent("Attack AP Rule:", "The AP cost of unit's attack");
        contL = new GUIContent[attackAPRuleLabel.Length];
        for (int i = 0; i < contL.Length; i++)
        {
            contL[i] = new GUIContent(attackAPRuleLabel[i], attackAPRuleTooltip[i]);
        }
        attackRule          = EditorGUILayout.IntPopup(cont, attackRule, contL, intVal, GUILayout.ExpandWidth(true));
        gc.attackAPCostRule = (_AttackAPCostRule)attackRule;

        /*
         * if(gc.attackAPCostRule==_AttackAPCostRule.PerAttack){
         *      cont=new GUIContent("AP Cost Per Attack:", "AP cost for unit to perform each attack");
         *      gc.attackAPCost=EditorGUILayout.IntField(cont, gc.attackAPCost);
         * }
         */


        cont = new GUIContent("Win Point Reward:", "point reward for winning this battle");
        gc.winPointReward = EditorGUILayout.IntField(cont, gc.winPointReward);


        cont         = new GUIContent("Next Scene:", "the name of next scene to be load");
        gc.nextScene = EditorGUILayout.TextField(cont, gc.nextScene);
        cont         = new GUIContent("Main Menu:", "the name of the main menu scene");
        gc.mainMenu  = EditorGUILayout.TextField(cont, gc.mainMenu);

        cont = new GUIContent("Enable Unit Placement:", "check to enable player to hand place the starting unit before the battle start");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.enableUnitPlacement = EditorGUILayout.Toggle(gc.enableUnitPlacement, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        cont = new GUIContent("Enable Counter Attack:", "check to enable unit to perform counter attack in range (only when attacker is within attack range)");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.enableCounterAttack = EditorGUILayout.Toggle(gc.enableCounterAttack, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();


        cont = new GUIContent("Full AP On Start:", "check to start unit at full AP");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.fullAPOnStart = EditorGUILayout.Toggle(gc.fullAPOnStart, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        cont = new GUIContent("Restore AP On New Round:", "check to restore unit AP to full at every new round");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.fullAPOnNewRound = EditorGUILayout.Toggle(gc.fullAPOnNewRound, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();


        cont = new GUIContent("Enable Cover System:", "check to use cover system\nunit behind an obstacle will gain bonus defense against attack from other side of cover");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.enableCover = EditorGUILayout.Toggle(gc.enableCover, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        if (gc.enableCover)
        {
            cont = new GUIContent("- Half Cover Bonus:", "hit penalty when attacking a target behind a half cover\ntakes value from 0-1");
            gc.coverBonusHalf = EditorGUILayout.FloatField(cont, gc.coverBonusHalf);

            cont = new GUIContent("- Full Cover Bonus:", "hit penalty when attacking a target behind a full cover\ntakes value from 0-1");
            gc.coverBonusFull = EditorGUILayout.FloatField(cont, gc.coverBonusFull);

            cont = new GUIContent("- Flanking Crit Bonus:", "critical bonus gain when attacking a unit with no cover\ntakes value from 0-1");
            gc.exposedCritBonus = EditorGUILayout.FloatField(cont, gc.exposedCritBonus);

            gc.coverBonusHalf = Mathf.Clamp(gc.coverBonusHalf, 0f, 1f);
            gc.coverBonusFull = Mathf.Clamp(gc.coverBonusFull, 0f, 1f);
        }

        cont = new GUIContent("Enable Fog of War:", "check to enable fog of war\nunit cannot see enemies beyond sight and out of line-of sight");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.enableFogOfWar = EditorGUILayout.Toggle(gc.enableFogOfWar, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        if (gc.enableFogOfWar)
        {
            gc.hotseat = false;
        }


        cont = new GUIContent("Allow Movement After Attack:", "check to allow unit to move after attack");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.allowMovementAfterAttack = EditorGUILayout.Toggle(gc.allowMovementAfterAttack, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        cont = new GUIContent("Allow Ability After Attack:", "check to allow unit to use ability after attack");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.allowAbilityAfterAttack = EditorGUILayout.Toggle(gc.allowAbilityAfterAttack, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        /*
         * if(gc.turnMode==_TurnMode.FactionSingleUnitPerTurnSingle){
         *      cont=new GUIContent("Allow Unit Switching:", "check to allow player to switch unit in play when in FactionBasedSingleUnit turn-mode");
         *      EditorGUILayout.BeginHorizontal("");
         *      EditorGUILayout.LabelField(cont, GUILayout.MinWidth(230));
         *      gc.allowUnitSwitching=EditorGUILayout.Toggle(gc.allowUnitSwitching);
         *      EditorGUILayout.EndHorizontal();
         * }
         */


        cont = new GUIContent("Action Cam Frequency:", "The rate at which action-cam will be used. value from 0-1. 0 being no action-cam, 1 being always action-cam");
        gc.actionCamFrequency = EditorGUILayout.FloatField(cont, gc.actionCamFrequency);


        if (GUI.changed)
        {
            EditorUtility.SetDirty(gc);
        }
    }
Esempio n. 30
0
    //code execution for when a left mouse click happen on a tile and when a touch is double tap on a tile
    public void OnTouchMouseDown()
    {
                #if !UNITY_IPHONE && !UNITY_ANDROID
        if (GameControlTB.IsCursorOnUI(Input.mousePosition))
        {
            return;
        }
        //if(GameControlTB.IsObjectOnUI(pos)) return;
                #endif

        if (GameControlTB.IsUnitPlacementState())
        {
            PlaceUnit();
            return;
        }

        if (GameControlTB.GetTurnMode() != _TurnMode.SingleUnitPerTurn)
        {
            if (!GameControlTB.IsPlayerTurn())
            {
                //if(GameControlTB.turnID!=GameControlTB.GetPlayerFactionTurnID()){
                return;
            }
        }

        if (GameControlTB.IsActionInProgress())
        {
            return;
        }

        if (!walkable && !GridManager.IsInTargetTileSelectMode())
        {
            return;
        }

        UnitTB sUnit = UnitControl.selectedUnit;

        //if a friendly unit has been selected
        //if(sUnit!=null && sUnit.IsControllable(GameControlTB.GetPlayerFactionID())){
        if (sUnit != null && sUnit.IsControllable())
        {
            //if HexFridManager is actively looking for a target for current selectedUnit
            if (GridManager.IsInTargetTileSelectMode())
            {
                ManualSelect();
            }
            else
            {
                if (!walkableToSelected && !attackableToSelected)
                {
                    ManualSelect();
                }
                else
                {
                    if (attackableToSelected && unit != null)
                    {
                        sUnit.Attack(unit);
                    }
                    else if (walkableToSelected)
                    {
                        sUnit.Move(this);
                    }
                    else
                    {
                        Debug.Log("error");
                    }
                }
            }

            return;
        }
        else
        {
            ManualSelect();
        }
    }
Esempio n. 31
0
    void Awake()
    {
        LoadUnit();
        LoadObstacle();
        LoadCollectible();

        rotationLabel=new string[7];
        rotationLabel[0]="Random";
        rotationLabel[1]="0";
        rotationLabel[2]="60";
        rotationLabel[3]="120";
        rotationLabel[4]="180";
        rotationLabel[5]="240";
        rotationLabel[6]="300";

        int enumLength = Enum.GetValues(typeof(_TileType)).Length;
        tileTypeLabel=new string[enumLength];
        for(int i=0; i<enumLength; i++) tileTypeLabel[i]=((_TileType)i).ToString();

        tileTypeTooltip=new string[enumLength];
        tileTypeTooltip[0]="Use HexTile";
        tileTypeTooltip[1]="Use SquareTile";

        enumLength = Enum.GetValues(typeof(_SpawnQuota)).Length;
        spawnQuotaLabel=new string[enumLength];
        for(int i=0; i<enumLength; i++) spawnQuotaLabel[i]=((_SpawnQuota)i).ToString();

        spawnQuotaTooltip=new string[enumLength];
        spawnQuotaTooltip[0]="Spawn a set number of unit for the area\nEach prefab have a spawn limit";
        spawnQuotaTooltip[1]="Spawn a varied number of unit for the area based on the point budget available";

        gc=(GameControlTB)FindObjectOfType(typeof(GameControlTB));
    }
Esempio n. 32
0
    public override void OnInspectorGUI()
    {
        gm = (GridManager)target;

        //DrawDefaultInspector();

        EditorGUILayout.Space();

        cont=new GUIContent("Randomize Grid On Start", "check to regenerate the tiles when the scene is loaded\nthis will generate all the units as well");
        gm.randomizeGridUponStart=EditorGUILayout.Toggle(cont, gm.randomizeGridUponStart);

        cont=new GUIContent("Randomize Unit On Start", "check to regenerate the units on the grid when the scene is loaded\nexisting unit will be removed");
        gm.randomizeUnitUponStart=EditorGUILayout.Toggle(cont, gm.randomizeUnitUponStart);

        cont=new GUIContent("Show Gizmo", "check to show gizmos on scene view");
        gm.showGizmo=EditorGUILayout.Toggle(cont, gm.showGizmo);

        EditorGUILayout.Space();

        int type=(int)gm.type;
        cont=new GUIContent("Grid Type:", "Turn mode to be used in this scene");
        contL=new GUIContent[tileTypeLabel.Length];
        for(int i=0; i<contL.Length; i++) contL[i]=new GUIContent(tileTypeLabel[i], tileTypeTooltip[i]);
        type = EditorGUILayout.IntPopup(cont, type, contL, intVal);
        gm.type=(_TileType)type;

        cont=new GUIContent("Grid Size:", "The size of a single tile of the grid");
        gm.gridSize=EditorGUILayout.FloatField(cont, gm.gridSize);

        EditorGUILayout.BeginHorizontal();
        cont=new GUIContent("Num of Column:", "the width(x-axis) of the area to cover for the whole grid");
        gm.width=EditorGUILayout.FloatField(cont, gm.width, GUILayout.ExpandWidth(true));
        //~ gm.width=EditorGUILayout.FloatField(cont, gm.width, GUILayout.MinWidth(160));
        //~ gm.width=Mathf.Round(Mathf.Clamp(gm.width, 0, 50));
        //~ cont=new GUIContent("Actual:"+(gm.width*gm.gridSize).ToString("f2"), "after multiply the GridSize");
        //~ EditorGUILayout.LabelField(cont, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        cont=new GUIContent("Num of Row:", "the length(z-axis) of the area to cover for the whole grid");
        gm.length=EditorGUILayout.FloatField(cont, gm.length, GUILayout.ExpandWidth(true));
        //~ gm.length=EditorGUILayout.FloatField(cont, gm.length, GUILayout.MinWidth(160));
        //~ gm.length=Mathf.Round(Mathf.Clamp(gm.length, 0, 50));
        //~ cont=new GUIContent("Actual:"+(gm.length*gm.gridSize).ToString("f2"), "after multiply the GridSize");
        //~ EditorGUILayout.LabelField(cont, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        cont=new GUIContent("Area Height:", "the position of the grid on y-axis\nThis is a relative value from the GridManager's transform");
        gm.baseHeight=EditorGUILayout.FloatField(cont, gm.baseHeight);
        //cont=new GUIContent("Max Height:", "the position of the grid on y-axis\nThis is a relative value from the GridManager's transform");
        //gm.maxHeight=EditorGUILayout.FloatField(cont, gm.maxHeight);

        cont=new GUIContent("GridToTileSizeRatio:", "the size ratio of a single unit in the grid with respect to an individual tile");
        gm.gridToTileSizeRatio=EditorGUILayout.FloatField(cont, gm.gridToTileSizeRatio);
        gm.gridToTileSizeRatio=Mathf.Max(0, gm.gridToTileSizeRatio);

        cont=new GUIContent("UnwalkableTileRate:", "the percentage of the unwalkable tile of the whole grid");
        gm.unwalkableRate=EditorGUILayout.FloatField(cont, gm.unwalkableRate);
        gm.unwalkableRate=Mathf.Clamp(gm.unwalkableRate, 0f, 1f);

        if(gm.unwalkableRate>0){
            cont=new GUIContent("UseObstacle:", "the percentage of the unwalkable tile of the whole grid");
            gm.useObstacle=EditorGUILayout.Toggle(cont, gm.useObstacle);

            bool changedFlag=GUI.changed;

            if(gm.useObstacle){
                for(int n=0; n<obstacleList.Count; n++){

                    GUI.changed=false;

                    bool flag=false;
                    if(n==0) flag=gm.enableInvUnwalkable;
                    else if(n==1) flag=gm.enableVUnwalkable;
                    else{
                        if(gm.obstaclePrefabList.Contains(obstacleList[n])) flag=true;
                    }

                    cont=new GUIContent("  -  "+obstacleNameList[n]+":", "");
                    flag=EditorGUILayout.Toggle(cont, flag);

                    if(n==0) gm.enableInvUnwalkable=flag;
                    else if(n==1) gm.enableVUnwalkable=flag;
                    else{
                        if(GUI.changed){
                            if(gm.obstaclePrefabList.Contains(obstacleList[n]))
                                gm.obstaclePrefabList.Remove(obstacleList[n]);
                            else gm.obstaclePrefabList.Add(obstacleList[n]);

                            GUI.changed=false;
                        }
                    }
                }
            }

            if(gm.obstaclePrefabList.Count==0){
                if(!gm.enableInvUnwalkable && !gm.enableVUnwalkable){
                    gm.enableVUnwalkable=true;
                }
            }

            EditorGUILayout.Space();
            if(!GUI.changed) GUI.changed=changedFlag;
        }
        else EditorGUILayout.Space();

        cont=new GUIContent("AddCollectible:", "check to add collectible items to the grid when generating the grid");
        gm.addColletible=EditorGUILayout.Toggle(cont, gm.addColletible);

        if(gm.addColletible){

            EditorGUILayout.BeginHorizontal();
            cont=new GUIContent("CollectibleCount (min/max):", "The number of collectible to be spawned on the grid");
            EditorGUILayout.LabelField(cont, GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
            gm.minCollectibleCount=EditorGUILayout.IntField(gm.minCollectibleCount, GUILayout.MaxWidth(30));
            gm.maxCollectibleCount=EditorGUILayout.IntField(gm.maxCollectibleCount, GUILayout.MaxWidth(30));
            EditorGUILayout.EndHorizontal();

            bool changedFlag=GUI.changed;

            if(collectibleList.Count>0){
                for(int n=0; n<collectibleList.Count; n++){

                    GUI.changed=false;

                    bool flag=false;
                    if(gm.collectiblePrefabList.Contains(collectibleList[n])) flag=true;

                    cont=new GUIContent("  -  "+collectibleNameList[n]+":", "");
                    flag=EditorGUILayout.Toggle(cont, flag);

                    if(GUI.changed){
                        if(gm.collectiblePrefabList.Contains(collectibleList[n]))
                            gm.collectiblePrefabList.Remove(collectibleList[n]);
                        else gm.collectiblePrefabList.Add(collectibleList[n]);

                        GUI.changed=false;
                    }
                }
            }
            else{
                EditorGUILayout.LabelField("- No collectible in CollectibleManager -");
            }

            EditorGUILayout.Space();
            if(!GUI.changed) GUI.changed=changedFlag;
        }
        else EditorGUILayout.Space();

        //cont=new GUIContent("Tile Prefab:", "the gameObject prefab to be used as the tile");
        //gm.tilePrefab=(GameObject)EditorGUILayout.ObjectField(cont, gm.tilePrefab, typeof(GameObject), false);

        if(gm.type==_TileType.Hex){
            cont=new GUIContent("HexTile Prefab:", "the gameObject prefab to be used as the tile");
            gm.hexTilePrefab=(GameObject)EditorGUILayout.ObjectField(cont, gm.hexTilePrefab, typeof(GameObject), false);
        }
        else if(gm.type==_TileType.Square){
            cont=new GUIContent("SquareTile Prefab:", "the gameObject prefab to be used as the tile");
            gm.squareTilePrefab=(GameObject)EditorGUILayout.ObjectField(cont, gm.squareTilePrefab, typeof(GameObject), false);
        }

        if(gc!=null){
            if(gc.playerFactionID.Count!=gm.playerPlacementAreas.Count) gm.playerPlacementAreas=MatchRectListLength(gm.playerPlacementAreas, gc.playerFactionID.Count);

            for(int i=0; i<gc.playerFactionID.Count; i++){
                EditorGUILayout.Space();
                cont=new GUIContent("Player (ID:"+gc.playerFactionID[i]+") Placement Area:", "The area on the grid which player will be able to place the starting unit, as shown as the green colored square on the gizmo");
                gm.playerPlacementAreas[i]=EditorGUILayout.RectField(cont,  gm.playerPlacementAreas[i]);
            }

            if(gc.playerFactionID.Count==0){
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("No player faction set in GameControl");
            }
        }
        else{
            gc=(GameControlTB)FindObjectOfType(typeof(GameControlTB));
        }
        EditorGUILayout.Space();

        //cont=new GUIContent("Player Placement Area:", "The area on the grid which player will be able to place the starting unit, as shown as the green colored square on the gizmo");
        //gm.playerPlacementArea=EditorGUILayout.RectField(cont,  gm.playerPlacementArea);

        //~ showIndicatorList
        string label="Indicators (Show)";
        if(showIndicatorList) label="Indicators (Hide)";
        cont=new GUIContent(label, "list of various indicators used in run time. Optional. If left empty the defaults will be loaded");
        showIndicatorList = EditorGUILayout.Foldout(showIndicatorList, cont);
        if(showIndicatorList){
            gm.indicatorSelect=(Transform)EditorGUILayout.ObjectField("IndicatorSelect:", gm.indicatorSelect, typeof(Transform), false);
            gm.indicatorCursor=(Transform)EditorGUILayout.ObjectField("IndicatorCursor:", gm.indicatorCursor, typeof(Transform), false);
            gm.indicatorHostile=(Transform)EditorGUILayout.ObjectField("IndicatorHostile:", gm.indicatorHostile, typeof(Transform), false);
        }

        //~ gm.playerPlacementArea=EditorGUILayout.RectField("Player Placement Area:", gm.playerPlacementArea);

        int num;

        label="Faction (Show)";
        if(showFactionList) label="Faction (Hide)";
        cont=new GUIContent(label, "list of factions in this scene.");
        showFactionList = EditorGUILayout.Foldout(showFactionList, cont);
        if(showFactionList){
            GUILayout.BeginHorizontal();	GUILayout.Space (15);
            GUILayout.BeginVertical();

            cont=new GUIContent("Add Faction", "add a new faction to the list");
            if(GUILayout.Button(cont)){
                Faction fac=new Faction();
                fac.factionID=gm.factionList.Count;
                fac.color=new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), 1);
                gm.factionList.Add(fac);
            }

            for(int i=0; i<gm.factionList.Count; i++){
                Rect rectBase = EditorGUILayout.BeginVertical();
                GUILayout.Space (5);
                rectBase.width+=5;	rectBase.height+=0;
                GUI.Box(rectBase, "");

                Faction fac=gm.factionList[i];
                cont=new GUIContent("ID:", "The ID of the faction. 2 factions entry will the same ID will be recognised as 1 faction in runtime. Player's faction's ID is 0 by default");
                fac.factionID = EditorGUILayout.IntField(cont, fac.factionID);
                cont=new GUIContent("Color:", "Color of the faction. This is simply for gizmo purpose to identify different spawn area in SceneView");
                fac.color = EditorGUILayout.ColorField(cont, fac.color);

                cont=new GUIContent("Add Area", "add an additional spawn area for the faction");
                if(GUILayout.Button(cont)){
                    FactionSpawnInfo sInfo=new FactionSpawnInfo();
                    if(fac.spawnInfo.Count>0){
                        sInfo.area.x=fac.spawnInfo[fac.spawnInfo.Count-1].area.x;
                        sInfo.area.y=fac.spawnInfo[fac.spawnInfo.Count-1].area.y;
                        sInfo.area.width=fac.spawnInfo[fac.spawnInfo.Count-1].area.width;
                        sInfo.area.height=fac.spawnInfo[fac.spawnInfo.Count-1].area.height;
                    }
                    fac.spawnInfo.Add(sInfo);
                }

                GUILayout.BeginHorizontal();	GUILayout.Space (10);
                GUILayout.BeginVertical();

                for(int nn=0; nn<fac.spawnInfo.Count; nn++){
                    FactionSpawnInfo sInfo=fac.spawnInfo[nn];

                    Rect rectSub = EditorGUILayout.BeginVertical();
                    rectSub.x-=5; rectSub.width+=10;	rectSub.height+=5;
                    GUI.Box(rectSub, "");

                    int spawnQuota=(int)sInfo.spawnQuota;
                    cont=new GUIContent("SpawnQuota:", "type of spawning algorithm to be used");
                    contL=new GUIContent[spawnQuotaLabel.Length];
                    for(int n=0; n<contL.Length; n++) contL[n]=new GUIContent(spawnQuotaLabel[n], spawnQuotaTooltip[n]);
                    spawnQuota = EditorGUILayout.IntPopup(cont, spawnQuota, contL, intVal);
                    sInfo.spawnQuota=(_SpawnQuota)spawnQuota;

                    if(sInfo.spawnQuota==_SpawnQuota.UnitBased){
                        cont=new GUIContent("Number to Spawn:", "number of unit to spawn for this spawn area");
                        sInfo.unitCount=EditorGUILayout.IntField(cont, sInfo.unitCount, GUILayout.MaxHeight(14));
                    }
                    else if(sInfo.spawnQuota==_SpawnQuota.BudgetBased){
                        cont=new GUIContent("Spawn Budget:", "Point budget allocated for the units to be spawned");
                        sInfo.budget=EditorGUILayout.IntField(cont, sInfo.budget, GUILayout.MaxHeight(14));
                    }

                    cont=new GUIContent("Spawn Area:", "The area covered in which the units will be spawned in");
                    sInfo.area=EditorGUILayout.RectField(cont, sInfo.area);

                    cont=new GUIContent("Rotation:", "The direction which the unit spawned in this area will be facing");
                    contL=new GUIContent[rotationLabel.Length];
                    for(int n=0; n<contL.Length; n++) contL[n]=new GUIContent(rotationLabel[n], "");
                    sInfo.unitRotation = EditorGUILayout.IntPopup(cont, sInfo.unitRotation, contL, intVal);

                    label="Unit Prefab Pool (Show)";
                    if(sInfo.showUnitPrefabList) label="Unit Prefab Pool (Hide)";
                    cont=new GUIContent(label, "the list possible unit to be spawned in the area specified");
                    sInfo.showUnitPrefabList = EditorGUILayout.Foldout(sInfo.showUnitPrefabList, label);
                    if(sInfo.showUnitPrefabList){
                        num=sInfo.unitPrefabs.Length;
                        num=EditorGUILayout.IntField("  num of prefab:", num, GUILayout.MaxHeight(14));
                        if(num!=sInfo.unitPrefabs.Length) sInfo.unitPrefabs=MatchUnitPrefabListLength(sInfo.unitPrefabs, num);
                        if(num!=sInfo.unitPrefabsMax.Length) sInfo.unitPrefabsMax=MatchUnitPrefabMaxListLength(sInfo.unitPrefabsMax, num);
                        for(int n=0; n<num; n++){
                            int unitID=-1;
                            for(int m=0; m<unitList.Count; m++){
                                if(unitList[m]==sInfo.unitPrefabs[n]){
                                    unitID=m;
                                    break;
                                }
                            }

                            EditorGUILayout.BeginHorizontal();
                                if(sInfo.spawnQuota==_SpawnQuota.UnitBased){
                                    unitID = EditorGUILayout.IntPopup("   - unit"+n+"(max): ", unitID, unitNameList, intVal,  GUILayout.MaxHeight(13));
                                    sInfo.unitPrefabsMax[n] = EditorGUILayout.IntField(sInfo.unitPrefabsMax[n], GUILayout.MaxWidth(25));
                                }
                                else if(sInfo.spawnQuota==_SpawnQuota.BudgetBased){
                                    unitID = EditorGUILayout.IntPopup("   - unit"+n+"(max): ", unitID, unitNameList, intVal);
                                }
                            EditorGUILayout.EndHorizontal();

                            if(unitID>=0) sInfo.unitPrefabs[n]=unitList[unitID];
                            else sInfo.unitPrefabs[n]=null;
                        }
                    }

                    int totalUnitCount=0;
                    for(int n=0; n<sInfo.unitPrefabsMax.Length; n++) totalUnitCount+=sInfo.unitPrefabsMax[n];

                    sInfo.unitCount=Mathf.Min(totalUnitCount, sInfo.unitCount);

                    cont=new GUIContent("Remove area", "remove this spawn area");
                    if(GUILayout.Button(cont)){
                        fac.spawnInfo.Remove(sInfo);
                    }

                    EditorGUILayout.EndVertical();
                }

                GUILayout.EndVertical();
                GUILayout.Space (10);
                GUILayout.EndHorizontal ();

                GUILayout.Space (5);
                if(GUILayout.Button("Remove Faction")){
                    gm.factionList.Remove(fac);
                }
                GUILayout.Space (5);

                EditorGUILayout.EndVertical();

                GUILayout.Space (5);
            }
            GUILayout.Space (10);
            GUILayout.EndVertical();
            //~ GUILayout.Space (5);
            GUILayout.EndHorizontal ();
        }

        EditorGUILayout.Space();
            cont=new GUIContent("Generate Grid", "Procedurally generate a new grid with the configured setting\nPlease note that generate a large map (30x30 and above) might take a while");
            if(GUILayout.Button(cont)) GenerateGrid();

            cont=new GUIContent("Generate Unit", "Procedurally place unit on the grid with the configured setting");
            if(GUILayout.Button(cont)) GenerateUnit();

            //~ if(GUILayout.Button("testGenerate")) TestGenerate();
            //~ if(GUILayout.Button("testDestroy")) TestDestroy();
        EditorGUILayout.Space();

        if(GUI.changed){
            EditorUtility.SetDirty(gm);
        }
    }
Esempio n. 33
0
    public override void OnInspectorGUI()
    {
        //uc = (UnitControl)target;
        if (gc == null)
        {
            gc = uc.gameObject.GetComponent <GameControlTB>();
            if (gc == null)
            {
                Debug.Log("No GameControlTB component on UnitControl Object");
                return;
            }
            else
            {
                InitPlayerUnitsList();
            }
        }

        DrawDefaultInspector();



        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Starting Units");

        for (int n = 0; n < uc.playerUnits.Count; n++)
        {
            PlayerUnits pUnits = uc.playerUnits[n];

            int num = pUnits.starting.Count;

            //~ EditorGUILayout.BeginHorizontal();
            string label = "FactionID:" + pUnits.factionID.ToString() + " (show unit)";
            if (pUnits.showInInspector)
            {
                label = "FactionID:" + pUnits.factionID.ToString() + " (hide unit)";
            }
            cont = new GUIContent(label, "The player faction's unit to be deployed at the start of the scene");
            pUnits.showInInspector = EditorGUILayout.Foldout(pUnits.showInInspector, cont);
            //~ EditorGUILayout.EndHorizontal();

            if (pUnits.showInInspector)
            {
                num = EditorGUILayout.IntField("  Number of units:", num, GUILayout.MaxHeight(14));
                if (num != pUnits.starting.Count)
                {
                    pUnits.starting = MatchStartingUnitListLength(pUnits.starting, num);
                }
                for (int i = 0; i < num; i++)
                {
                    int unitID = -1;
                    for (int j = 0; j < unitList.Count; j++)
                    {
                        if (pUnits.starting[i] != null)
                        {
                            if (unitList[j].prefabID == pUnits.starting[i].prefabID)
                            {
                                unitID = j;
                                break;
                            }
                        }
                    }
                    unitID = EditorGUILayout.IntPopup("     - unit" + i + ": ", unitID, unitNameList, intVal, GUILayout.MaxHeight(13));

                    if (!Application.isPlaying)
                    {
                        if (unitID >= 0)
                        {
                            pUnits.starting[i] = unitList[unitID];
                        }
                        else
                        {
                            pUnits.starting[i] = null;
                        }
                    }
                }
            }
            EditorGUILayout.Space();
        }

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        cont = new GUIContent("Faction Colors:", "optional colors assignment to faction in runtime as displayed on the overlay. First color assigned to the first faction and so on. If left unassigned, a random color will be used instead");
        EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(120));
        if (GUILayout.Button("+", GUILayout.MaxWidth(50)))
        {
            uc.factionColors.Add(Color.white);
        }
        if (GUILayout.Button("-", GUILayout.MaxWidth(50)))
        {
            if (uc.factionColors.Count > 0)
            {
                uc.factionColors.RemoveAt(uc.factionColors.Count - 1);
            }
        }
        EditorGUILayout.EndHorizontal();
        for (int i = 0; i < uc.factionColors.Count; i++)
        {
            uc.factionColors[i] = EditorGUILayout.ColorField("Faction" + i, uc.factionColors[i]);
        }


        EditorGUILayout.Space();

        /*
         * //old code before hot seat mode, obsoleted
         * int numm=uc.startingUnit.Count;
         *
         * string labell="Starting Units (Show)";
         * if(showStartingUnitList) labell="Starting Units (Hide)";
         * cont=new GUIContent(labell, "The player unit ready to be deployed at the start of the scene");
         * showStartingUnitList = EditorGUILayout.Foldout(showStartingUnitList, cont);
         * if(showStartingUnitList){
         *      numm=EditorGUILayout.IntField("  Number of units:", numm, GUILayout.MaxHeight(14));
         *      if(numm!=uc.startingUnit.Count) uc.startingUnit=MatchStartingUnitListLength(uc.startingUnit, numm);
         *      for(int i=0; i<numm; i++){
         *              int unitID=-1;
         *              for(int j=0; j<unitList.Count; j++){
         *                      if(uc.startingUnit[i]!=null){
         *                              if(unitList[j].prefabID==uc.startingUnit[i].prefabID){
         *                                      unitID=j;
         *                                      break;
         *                              }
         *                      }
         *              }
         *              unitID = EditorGUILayout.IntPopup("     - unit"+i+": ", unitID, unitNameList, intVal,  GUILayout.MaxHeight(13));
         *              if(unitID>=0) uc.startingUnit[i]=unitList[unitID];
         *              else uc.startingUnit[i]=null;
         *      }
         * }
         */

        EditorGUILayout.Space();
    }
Esempio n. 34
0
    //apply a unit ability to the tile
    public void ApplyAbility(UnitAbility ability)
    {
        //spawn effect if any
        if (ability.effectTarget != null)
        {
            StartCoroutine(SpawnAbilityEffect(ability.effectTarget, ability.effectTargetDelay, pos));
        }

        //loop through the effect list and change the modifier
        //commented effect are disabled for tile
        foreach (EffectAttr effectAttr in ability.effectAttrs)
        {
            if (effectAttr.type == _EffectAttrType.HPDamage)
            {
                effectAttr.value = Random.Range(effectAttr.value, effectAttr.valueAlt);
                HPGainModifier  -= (int)effectAttr.value;
                if (unit != null)
                {
                    unit.ApplyDamage((int)effectAttr.value);
                }
            }
            else if (effectAttr.type == _EffectAttrType.HPGain)
            {
                effectAttr.value = Random.Range(effectAttr.value, effectAttr.valueAlt);
                HPGainModifier  += (int)effectAttr.value;
                if (unit != null)
                {
                    unit.ApplyHeal((int)effectAttr.value);
                }
            }
            else if (effectAttr.type == _EffectAttrType.APDamage)
            {
                effectAttr.value = Random.Range(effectAttr.value, effectAttr.valueAlt);
                APGainModifier  += (int)effectAttr.value;
                if (unit != null)
                {
                    unit.GainAP(-(int)effectAttr.value);
                }
            }
            else if (effectAttr.type == _EffectAttrType.APGain)
            {
                effectAttr.value = Random.Range(effectAttr.value, effectAttr.valueAlt);
                APGainModifier  -= (int)effectAttr.value;
                if (unit != null)
                {
                    unit.GainAP((int)effectAttr.value);
                }
            }
            else if (effectAttr.type == _EffectAttrType.Damage)
            {
                damageModifier += (int)effectAttr.value;
            }
            //~ else if(effectAttr.type==_EffectAttrType.MovementRange){
            //~ movementModifier+=(int)effectAttr.value;
            //~ }
            else if (effectAttr.type == _EffectAttrType.AttackRange)
            {
                attRangeModifier += (int)effectAttr.value;
            }
            //~ else if(effectAttr.type==_EffectAttrType.Speed){
            //~ speedModifier+=(int)effectAttr.value;
            //~ }
            else if (effectAttr.type == _EffectAttrType.HitChance)
            {
                attackModifier += effectAttr.value;
            }
            else if (effectAttr.type == _EffectAttrType.DodgeChance)
            {
                defendModifier += effectAttr.value;
            }
            else if (effectAttr.type == _EffectAttrType.CriticalChance)
            {
                criticalModifier += effectAttr.value;
            }
            else if (effectAttr.type == _EffectAttrType.CriticalImmunity)
            {
                critDefModifier += effectAttr.value;
            }
            //~ else if(effectAttr.type==_EffectAttrType.ExtraAttack){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.ExtraCounterAttack){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.Stun){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.DisableAttack){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.DisableMovement){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.DisableAbility){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.Teleport){

            //~ }
        }

        if (activeUnitAbilityEffectList.Count == 0)
        {
            SubscribeEvent();
            if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
            {
                countTillNextTurn = UnitControl.activeFactionCount;
            }
            else
            {
                countTillNextTurn = UnitControl.GetAllUnitCount();
            }
        }

        if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
        {
            ability.countTillNextTurn = UnitControl.activeFactionCount;
        }
        else
        {
            ability.countTillNextTurn = UnitControl.GetAllUnitCount();
        }

        //add the ability to the list so it can be keep tracked
        activeUnitAbilityEffectList.Add(ability);
    }
Esempio n. 35
0
    public override void OnInspectorGUI()
    {
        //uc = (UnitControl)target;
        if(gc==null){
            gc=uc.gameObject.GetComponent<GameControlTB>();
            if(gc==null){
                Debug.Log("No GameControlTB component on UnitControl Object");
                return;
            }
            else{
                InitPlayerUnitsList();
            }
        }

        DrawDefaultInspector();

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Starting Units");

        for(int n=0; n<uc.playerUnits.Count; n++){
            PlayerUnits pUnits=uc.playerUnits[n];

            int num=pUnits.starting.Count;

            //~ EditorGUILayout.BeginHorizontal();
                string label="FactionID:"+pUnits.factionID.ToString()+" (show unit)";
                if(pUnits.showInInspector) label="FactionID:"+pUnits.factionID.ToString()+" (hide unit)";
                cont=new GUIContent(label, "The player faction's unit to be deployed at the start of the scene");
                pUnits.showInInspector = EditorGUILayout.Foldout(pUnits.showInInspector, cont);
            //~ EditorGUILayout.EndHorizontal();

            if(pUnits.showInInspector){
                num=EditorGUILayout.IntField("  Number of units:", num, GUILayout.MaxHeight(14));
                if(num!=pUnits.starting.Count) pUnits.starting=MatchStartingUnitListLength(pUnits.starting, num);
                for(int i=0; i<num; i++){
                    int unitID=-1;
                    for(int j=0; j<unitList.Count; j++){
                        if(pUnits.starting[i]!=null){
                            if(unitList[j].prefabID==pUnits.starting[i].prefabID){
                                unitID=j;
                                break;
                            }
                        }
                    }
                    unitID = EditorGUILayout.IntPopup("     - unit"+i+": ", unitID, unitNameList, intVal,  GUILayout.MaxHeight(13));

                    if(!Application.isPlaying){
                        if(unitID>=0) pUnits.starting[i]=unitList[unitID];
                        else pUnits.starting[i]=null;
                    }
                }
            }
            EditorGUILayout.Space();
        }

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        cont=new GUIContent("Faction Colors:", "optional colors assignment to faction in runtime as displayed on the overlay. First color assigned to the first faction and so on. If left unassigned, a random color will be used instead");
        EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(120));
        if(GUILayout.Button("+", GUILayout.MaxWidth(50))){
            uc.factionColors.Add(Color.white);
        }
        if(GUILayout.Button("-", GUILayout.MaxWidth(50))){
            if(uc.factionColors.Count>0){
                uc.factionColors.RemoveAt(uc.factionColors.Count-1);
            }
        }
        EditorGUILayout.EndHorizontal();
        for(int i=0; i<uc.factionColors.Count; i++){
            uc.factionColors[i]=EditorGUILayout.ColorField("Faction"+i, uc.factionColors[i]);
        }

        EditorGUILayout.Space();

        /*
        //old code before hot seat mode, obsoleted
        int numm=uc.startingUnit.Count;

        string labell="Starting Units (Show)";
        if(showStartingUnitList) labell="Starting Units (Hide)";
        cont=new GUIContent(labell, "The player unit ready to be deployed at the start of the scene");
        showStartingUnitList = EditorGUILayout.Foldout(showStartingUnitList, cont);
        if(showStartingUnitList){
            numm=EditorGUILayout.IntField("  Number of units:", numm, GUILayout.MaxHeight(14));
            if(numm!=uc.startingUnit.Count) uc.startingUnit=MatchStartingUnitListLength(uc.startingUnit, numm);
            for(int i=0; i<numm; i++){
                int unitID=-1;
                for(int j=0; j<unitList.Count; j++){
                    if(uc.startingUnit[i]!=null){
                        if(unitList[j].prefabID==uc.startingUnit[i].prefabID){
                            unitID=j;
                            break;
                        }
                    }
                }
                unitID = EditorGUILayout.IntPopup("     - unit"+i+": ", unitID, unitNameList, intVal,  GUILayout.MaxHeight(13));
                if(unitID>=0) uc.startingUnit[i]=unitList[unitID];
                else uc.startingUnit[i]=null;
            }
        }
        */

        EditorGUILayout.Space();
    }
Esempio n. 36
0
    public override void OnInspectorGUI()
    {
        gc = (GameControlTB)target;

        //DrawDefaultInspector();

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        int turnMode=(int)gc.turnMode;
        cont=new GUIContent("Turn Mode:", "Turn mode to be used in this scene");
        contL=new GUIContent[turnModeLabel.Length];
        for(int i=0; i<contL.Length; i++) contL[i]=new GUIContent(turnModeLabel[i], turnModeTooltip[i]);
        turnMode = EditorGUILayout.IntPopup(cont, turnMode, contL, intVal);
        gc.turnMode=(_TurnMode)turnMode;

        if(turnMode<=2){
            int moveOrder=(int)gc.moveOrder;
            cont=new GUIContent("Move Order:", "Unit move order to be used in this scene");
            contL=new GUIContent[moveOrderLabel.Length];
            for(int i=0; i<contL.Length; i++) contL[i]=new GUIContent(moveOrderLabel[i], moveOrderTooltip[i]);
            moveOrder = EditorGUILayout.IntPopup(cont, moveOrder, contL, intVal);
            gc.moveOrder=(_MoveOrder)moveOrder;
        }

        int loadMode=(int)gc.loadMode;
        cont=new GUIContent("Data Load Mode:", "Data loading mode to be used in this scene");
        contL=new GUIContent[loadModeLabel.Length];
        for(int i=0; i<contL.Length; i++) contL[i]=new GUIContent(loadModeLabel[i], loadModeTooltip[i]);
        loadMode = EditorGUILayout.IntPopup(cont, loadMode, contL, intVal);
        gc.loadMode=(_LoadMode)loadMode;

        cont=new GUIContent("Enable Perk Menu:", "check to enable PerkMenu to be brought out in the scene");
        EditorGUILayout.BeginHorizontal("");
        //EditorGUILayout.LabelField(cont);
        gc.enablePerkMenu=EditorGUILayout.Toggle(cont, gc.enablePerkMenu);
        EditorGUILayout.EndHorizontal();

        //cont=new GUIContent("PlayerFactionID:", "Numerial ID to identify player's units\nAny unit with similar unitID will be able to control by player\nif no unit with similar unitID is in the scene, the whole game will be run by AI");
        //gc.playerFactionID[0]=EditorGUILayout.IntField(cont, gc.playerFactionID[0]);

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        cont=new GUIContent("HotSeat Mode:", "check to enable local hot seat multiplayer\nenable multiple player faction");
        EditorGUILayout.BeginHorizontal("");
        //EditorGUILayout.LabelField(cont);
        gc.hotseat=EditorGUILayout.Toggle(cont, gc.hotseat);
        EditorGUILayout.EndHorizontal();

        if(gc.hotseat){
            gc.enableFogOfWar=false;

            if(gc.playerFactionID.Count==1){
                int ID=gc.playerFactionID[0];
                int newID=0;
                if(ID==0) newID=1;

                gc.playerFactionID.Add(newID);
                uc.playerUnits.Add(new PlayerUnits(newID));
            }

            for(int i=0; i<gc.playerFactionID.Count; i++){
                EditorGUILayout.BeginHorizontal("");
                    cont=new GUIContent("PlayerFactionID - "+i+":", "Numerial ID to identify player's units\nAny unit with similar unitID will be able to control by player\nif no unit with similar unitID is in the scene, the whole game will be run by AI");
                    int ID=gc.playerFactionID[i];
                    ID=EditorGUILayout.IntField(cont, ID, GUILayout.MaxHeight(16));
                    if(!gc.playerFactionID.Contains(ID)){
                        gc.playerFactionID[i]=ID;
                        uc.playerUnits[i].factionID=ID;
                    }
                    if(GUILayout.Button("Remove", GUILayout.MaxHeight(16))){
                        if(gc.playerFactionID.Count>2){
                            gc.playerFactionID.RemoveAt(i);
                            uc.playerUnits.RemoveAt(i);
                        }
                    }
                EditorGUILayout.EndHorizontal();
            }
            if(GUILayout.Button("Add more player", GUILayout.MaxHeight(16))){
                int newID=0;
                while(gc.playerFactionID.Contains(newID)) newID+=1;
                gc.playerFactionID.Add(newID);
                uc.playerUnits.Add(new PlayerUnits(newID));
            }
        }
        else{
            if(gc.playerFactionID.Count>1){
                //int ID=gc.playerFactionID[0];
                //gc.playerFactionID=new List<int>();
                //gc.playerFactionID.Add(ID);

                for(int i=0; i<gc.playerFactionID.Count-1; i++){
                    gc.playerFactionID.RemoveAt(1);
                    uc.playerUnits.RemoveAt(1);
                }
            }

            cont=new GUIContent("PlayerFactionID:", "Numerial ID to identify player's units\nAny unit with similar unitID will be able to control by player\nif no unit with similar unitID is in the scene, the whole game will be run by AI");
            gc.playerFactionID[0]=EditorGUILayout.IntField(cont, gc.playerFactionID[0]);
            uc.playerUnits[0].factionID=gc.playerFactionID[0];
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        int moveRule=(int)gc.movementAPCostRule;
        cont=new GUIContent("Movement AP Rule:", "The AP cost of unit's movement");
        contL=new GUIContent[moveAPRuleLabel.Length];
        for(int i=0; i<contL.Length; i++) contL[i]=new GUIContent(moveAPRuleLabel[i], moveAPRuleTooltip[i]);
        moveRule = EditorGUILayout.IntPopup(cont, moveRule, contL, intVal, GUILayout.ExpandWidth(true));
        gc.movementAPCostRule=(_MovementAPCostRule)moveRule;

        /*
        if(gc.movementAPCostRule==_MovementAPCostRule.PerMove){
            cont=new GUIContent("AP Cost Per Move:", "AP cost for unit to move");
            gc.movementAPCost=EditorGUILayout.IntField(cont, gc.movementAPCost);
        }
        else if(gc.movementAPCostRule==_MovementAPCostRule.PerTile){
            cont=new GUIContent("AP Cost Per Move:", "AP cost for unit to move across each tile");
            gc.movementAPCost=EditorGUILayout.IntField(cont, gc.movementAPCost);
        }
        */

        int attackRule=(int)gc.attackAPCostRule;
        cont=new GUIContent("Attack AP Rule:", "The AP cost of unit's attack");
        contL=new GUIContent[attackAPRuleLabel.Length];
        for(int i=0; i<contL.Length; i++) contL[i]=new GUIContent(attackAPRuleLabel[i], attackAPRuleTooltip[i]);
        attackRule = EditorGUILayout.IntPopup(cont, attackRule, contL, intVal, GUILayout.ExpandWidth(true));
        gc.attackAPCostRule=(_AttackAPCostRule)attackRule;

        /*
        if(gc.attackAPCostRule==_AttackAPCostRule.PerAttack){
            cont=new GUIContent("AP Cost Per Attack:", "AP cost for unit to perform each attack");
            gc.attackAPCost=EditorGUILayout.IntField(cont, gc.attackAPCost);
        }
        */

        cont=new GUIContent("Win Point Reward:", "point reward for winning this battle");
        gc.winPointReward=EditorGUILayout.IntField(cont, gc.winPointReward);

        cont=new GUIContent("Next Scene:", "the name of next scene to be load");
        gc.nextScene=EditorGUILayout.TextField(cont, gc.nextScene);
        cont=new GUIContent("Main Menu:", "the name of the main menu scene");
        gc.mainMenu=EditorGUILayout.TextField(cont, gc.mainMenu);

        cont=new GUIContent("Enable Unit Placement:", "check to enable player to hand place the starting unit before the battle start");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.enableUnitPlacement=EditorGUILayout.Toggle(gc.enableUnitPlacement, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        cont=new GUIContent("Enable Counter Attack:", "check to enable unit to perform counter attack in range (only when attacker is within attack range)");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.enableCounterAttack=EditorGUILayout.Toggle(gc.enableCounterAttack, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        cont=new GUIContent("Full AP On Start:", "check to start unit at full AP");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.fullAPOnStart=EditorGUILayout.Toggle(gc.fullAPOnStart, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        cont=new GUIContent("Restore AP On New Round:", "check to restore unit AP to full at every new round");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.fullAPOnNewRound=EditorGUILayout.Toggle(gc.fullAPOnNewRound, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        cont=new GUIContent("Enable Cover System:", "check to use cover system\nunit behind an obstacle will gain bonus defense against attack from other side of cover");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.enableCover=EditorGUILayout.Toggle(gc.enableCover, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        if(gc.enableCover){
            cont=new GUIContent("- Half Cover Bonus:", "hit penalty when attacking a target behind a half cover\ntakes value from 0-1");
            gc.coverBonusHalf=EditorGUILayout.FloatField(cont, gc.coverBonusHalf);

            cont=new GUIContent("- Full Cover Bonus:", "hit penalty when attacking a target behind a full cover\ntakes value from 0-1");
            gc.coverBonusFull=EditorGUILayout.FloatField(cont, gc.coverBonusFull);

            cont=new GUIContent("- Flanking Crit Bonus:", "critical bonus gain when attacking a unit with no cover\ntakes value from 0-1");
            gc.exposedCritBonus=EditorGUILayout.FloatField(cont, gc.exposedCritBonus);

            gc.coverBonusHalf=Mathf.Clamp(gc.coverBonusHalf, 0f, 1f);
            gc.coverBonusFull=Mathf.Clamp(gc.coverBonusFull, 0f, 1f);
        }

        cont=new GUIContent("Enable Fog of War:", "check to enable fog of war\nunit cannot see enemies beyond sight and out of line-of sight");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.enableFogOfWar=EditorGUILayout.Toggle(gc.enableFogOfWar, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        if(gc.enableFogOfWar) gc.hotseat=false;

        cont=new GUIContent("Allow Movement After Attack:", "check to allow unit to move after attack");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.allowMovementAfterAttack=EditorGUILayout.Toggle(gc.allowMovementAfterAttack, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        cont=new GUIContent("Allow Ability After Attack:", "check to allow unit to use ability after attack");
        EditorGUILayout.BeginHorizontal("");
        EditorGUILayout.LabelField(cont, GUILayout.MinWidth(180));
        gc.allowAbilityAfterAttack=EditorGUILayout.Toggle(gc.allowAbilityAfterAttack, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        /*
        if(gc.turnMode==_TurnMode.FactionSingleUnitPerTurnSingle){
            cont=new GUIContent("Allow Unit Switching:", "check to allow player to switch unit in play when in FactionBasedSingleUnit turn-mode");
            EditorGUILayout.BeginHorizontal("");
            EditorGUILayout.LabelField(cont, GUILayout.MinWidth(230));
            gc.allowUnitSwitching=EditorGUILayout.Toggle(gc.allowUnitSwitching);
            EditorGUILayout.EndHorizontal();
        }
        */

        cont=new GUIContent("Action Cam Frequency:", "The rate at which action-cam will be used. value from 0-1. 0 being no action-cam, 1 being always action-cam");
        gc.actionCamFrequency=EditorGUILayout.FloatField(cont, gc.actionCamFrequency);

        if(GUI.changed){
            EditorUtility.SetDirty(gc);
        }
    }
Esempio n. 37
0
	void Awake(){
		instance=this;
		
		turnID=-1;
		turnIDLoop=1;
		
		AbilityManagerTB.LoadUnitAbility();
		
		roundCounter=0;
		battleEnded=false;
		
		if(playerFactionID.Count==0) playerFactionID.Add(0);
	}