Example #1
0
 public void Init(UnitSize size, UnitShape shape, UnitColor color)
 {
     m_UnitGO = gameObject;
     m_Size   = size;
     m_Shape  = shape;
     m_Color  = color;
 }
Example #2
0
 public King(UnitColor unitColor, HashSet <int> potentialMoves)
 {
     _iKingMove = new KingMove();
     _allyCoord = UnitColor.White == unitColor ? ChessPieces.WhiteChessPieces.Item2 : ChessPieces.BlackChessPieces.Item2;
     //enemyPossibleCoordinateDictionary = UnitColor.WHITE == unitColor ? allPossibleMoves.GetAllBlackPossibleCoordinates() : allPossibleMoves.GetAllWhitePossibleCoordinates();
     _potentialMoves = potentialMoves;
 }
Example #3
0
    public int DugoutRegistration(HexCoord currentHex, UnitColor color, UnitType type)
    {
        int num = 1;

        if (color == UnitColor.White)
        {
            foreach (UnitType member in whitePieceList)
            {
                if (member == type)
                {
                    num++;
                }
            }
            whitePieceList.Add(type);
        }
        if (color == UnitColor.Black)
        {
            foreach (UnitType member in blackPieceList)
            {
                if (member == type)
                {
                    num++;
                }
            }
            blackPieceList.Add(type);
        }

        boardList.Add(PieceStringHelper(color, type, num));
        boardDict[PieceStringHelper(color, type, num)] = currentHex;

        return(num);
    }
Example #4
0
    void CreateMinion(string inputTag)
    {
        for (int i = 0; i < 30; i++)
        {
            // 미니언을 비 활성화된 상태로 생성한다.
            Unit minion = CreateUnit(YBEnum.eUnitName.Minion, UnitColor.PaseToEnum(inputTag), Vector3.zero);
            minion.onAi = false;

            // 게임 오브젝트를 비활성화 한다.
            minion.gameObject.SetActive(false);

            // 트랜스폼을 변경한다.
            minion.transform.SetParent(minionPool);


            if (inputTag.CompareTo("Yellow") == 0)
            {
                // 스택에 추가한다.
                stackYellowMinion.Push(minion);
            }
            else
            {
                // 스택에 추가한다.
                stackGreenMinion.Push(minion);
            }
        }
    }
Example #5
0
        public int GetTwoForwardMove(UnitColor unitColor, int rowPosition, int colPosition, HashSet <int> allyCoord, HashSet <int> enemyCoord, HashSet <int> protectAllyKingMoves, bool isInitialized = false)
        {
            var forward      = unitColor == UnitColor.White ? GetForwardCoordinate(rowPosition, colPosition) : GetBackwardCoordinate(rowPosition, colPosition);
            var forwardTwo   = unitColor == UnitColor.White ? GetForwardCoordinate(rowPosition, colPosition) + 10 : GetBackwardCoordinate(rowPosition, colPosition) - 10;
            var startLine    = unitColor == UnitColor.White ? 2 : 7;
            var possibleMove = 0;

            if (rowPosition == Max || rowPosition == Min)
            {
                return(0);
            }
            if (!allyCoord.Contains(forward) && !enemyCoord.Contains(forward))
            {
                if (rowPosition == startLine)
                {
                    if (!allyCoord.Contains(forwardTwo) && !enemyCoord.Contains(forwardTwo))
                    {
                        possibleMove = forwardTwo;
                    }
                }
            }

            if (isInitialized || !protectAllyKingMoves.Any())
            {
                return(possibleMove);
            }
            return(!protectAllyKingMoves.Contains(forwardTwo) ? 0 : possibleMove);
        }
Example #6
0
    public void setUnitColor(UnitColor p_unitColor)
    {
        m_unitColor = p_unitColor;

        Color color = GameManager.getInstance().getUnitColor(m_unitColor);

        setMainPrismColor(color);
    }
Example #7
0
 public UnitData(UnitColor color,
                 UnitType type,
                 BombType bombType)
 {
     this.color    = color;
     this.type     = type;
     this.bombType = bombType;
 }
	public void Init(InputDevice device, UnitColor color){
		base.Init(color);

		attackerActions = new AttackerActions(device);
		motor.Init(attackerActions);
		atk.Init(attackerActions);

	}
Example #9
0
	public void Init(UnitColor color){
		this.color = color;
		int index = (int)color;
		var playerSprite = playerSprites[index][0];
		var healthOnSprite = sprites[index];
		hsm.Init(healthOnSprite);
		spr.sprite = playerSprite;
	}
Example #10
0
    void StageData()
    {
        // 스토리 스테이지 데이타
        StoryStageData storyStageData = new StoryStageData();

        // 아이디를 입력한다.
        if (!int.TryParse(ifStageID.text, out storyStageData.id))
        {
            onSaveGo.SetActive(false);
            Debug.LogError("아이디를 확인하세요.");
            return;
        }

        // 타이틀을 입력한다.
        storyStageData.desc = ifStageDesc.text;

        // 코스트를 넣는다.
        if (!int.TryParse(ifStageCost.text, out storyStageData.cost))
        {
            onSaveGo.SetActive(false);
            Debug.LogError("코스트를 확인하세요.");
            return;
        }

        storyStageData.map_id = mapData.map_id;

        // 유닛 배열
        Unit[] arrUnit = GameObject.FindObjectsOfType <Unit>();

        for (int i = 0; i < arrUnit.Length; i++)
        {
            unit_info info = new unit_info();
            info.unit_name = arrUnit[i].status.name;
            info.color     = UnitColor.PaseToInt(arrUnit[i].tag.ToString());
            info.x         = arrUnit[i].transform.position.x;
            info.y         = arrUnit[i].transform.position.y;
            info.z         = 0;

            storyStageData.listUnitInfos.Add(info);
        }

        string path     = Application.dataPath + "/Resources/Data/StoryStageData/";
        string fileName = string.Format("story_stage_{0}.json", storyStageData.id);

        if (File.Exists(path + fileName))
        {
            Debug.LogError("중복된 파일 명 입니다.");
            onSaveGo.SetActive(false);
            return;
        }

        string json = JsonConvert.SerializeObject(storyStageData);

        File.WriteAllText(path + fileName, json);

        onSaveGo.SetActive(false);
    }
Example #11
0
 public void Init(UnitData curData)
 {
     _unitType  = curData.type;
     _bombType  = curData.bombType;
     _unitColor = curData.color;
     _moveState = UnitMoveState.Default;
     _elimState = UnitElimState.Default;
     UpdateCell();
 }
Example #12
0
    protected void Awake()
    {
        Armament  = GetComponent <CharacterAttack>();
        movement  = GetComponent <CharacterContrMovement>();
        unitColor = GetComponent <UnitColor>();
        List <IBonus> sourse = new List <IBonus>(GetComponents <IBonus>());

        characteristic = new Characteristic(sourse);
    }
Example #13
0
    void Summon()
    {
        YBEnum.eColorType color = UnitColor.PaseToEnum(sc.tag.ToString());

        // 소환을 한다.
        UnitsPool.instance.SummonMinion(sc.tag, sc.Position);
        UnitsPool.instance.SummonMinion(sc.tag, sc.Position);
        UnitsPool.instance.SummonMinion(sc.tag, sc.Position);
    }
Example #14
0
 public Knight(UnitColor unitColor, HashSet <int> protectEnemyKingMoves, HashSet <int> protectAllyKingMoves, HashSet <int> potentialMoves)
 {
     _iKnightMove           = new KnightMove();
     _allyCoord             = UnitColor.White == unitColor ? ChessPieces.WhiteChessPieces.Item2 : ChessPieces.BlackChessPieces.Item2;
     _enemyKing             = UnitColor.White == unitColor ? ChessPieces.BlackChessPieces.Item3 : ChessPieces.WhiteChessPieces.Item3;
     _protectEnemyKingMoves = protectEnemyKingMoves;
     _protectAllyKingMoves  = protectAllyKingMoves;
     _potentialMoves        = potentialMoves;
 }
Example #15
0
 public void DetermineMoveablePieces(UnitColor color)
 {
     if (HasQueenBeenPlaced(color))
     {
         CheckHiveContinuity();      //Populate the validMovePieces list based on maintaining hive continuity
     }
     else
     {
         validMovePieces.Clear();    //If queen hasn't been placed for this color then no pieces can be moved
     }
 }
Example #16
0
 public Bishop(UnitColor unitColor, HashSet <int> protectEnemyKingMoves, HashSet <int> protectAllyKingMoves, Dictionary <int, List <int> > coverKingMoves, HashSet <int> potentialMoves)
 {
     _iMoveDiagonal         = new MoveDiagonal();
     _allyCoord             = UnitColor.White == unitColor ? ChessPieces.WhiteChessPieces.Item2 : ChessPieces.BlackChessPieces.Item2;
     _enemyCoord            = UnitColor.White == unitColor ? ChessPieces.BlackChessPieces.Item2 : ChessPieces.WhiteChessPieces.Item2;
     _enemyKing             = UnitColor.White == unitColor ? ChessPieces.BlackChessPieces.Item3 : ChessPieces.WhiteChessPieces.Item3;
     _protectEnemyKingMoves = protectEnemyKingMoves;
     _protectAllyKingMoves  = protectAllyKingMoves;
     _coverKingMoves        = coverKingMoves;
     _potentialMoves        = potentialMoves;
 }
Example #17
0
 public bool MatchEliminateColor(UnitColor _elimColor)
 {
     if (!IsBombable)
     {
         return(false);
     }
     if (Unit.unitColor == _elimColor)
     {
         return(true);
     }
     return(false);
 }
Example #18
0
    // Used when a piece first enters the board to populate the type and color lists. Return piece number (if the second white spider then returns 2)
    public void RegisterPiece(HexCoord currentHex, UnitColor color, UnitType type)
    {
        //int index = GetIndex(currentHex);

        //colorList[index] = color;
        //typeList[index] = type;

        occupiedList.Add(currentHex);
        colorDict[currentHex]  = color;
        typeDict[currentHex]   = type;
        beetleDict[currentHex] = 0; //No beetles on top
    }
Example #19
0
    public BombInfo(CellCtrl triggerModel, float delay,int row,int col,BombCmd bombCmd = BombCmd.None,UnitType curType = UnitType.None,int curSubType = 0,UnitColor curColor = UnitColor.None)
    {
        _triggerModel = triggerModel;
        _row = row;
        _col = col;
        _delayTime = delay;
        _bombCmd = bombCmd;

        _formType = curType;
        _subType = curSubType;
        _formColor = curColor;
    }
Example #20
0
    public void updatePrismLayerColors()
    {
        int currentLayer = GameManager.getInstance().getCurrentLayer();

        for (int i = 0; i < m_prismLayerData.Length; i++)
        {
            PrismLayer prismLayer = m_prismLayerData[currentLayer].getPrismLayer(i);

            // Retrieving unit color using the real color
            UnitColor unitColor = GameManager.getInstance().getUnitColor(m_prismLayerColors[i]);
            prismLayer.setUnitColor(unitColor);
        }
    }
Example #21
0
        public Pawn(UnitColor unitColor, HashSet <int> protectEnemyKingMoves, HashSet <int> protectAllyKingMoves, HashSet <int> potentialMoves)
        {
            var chessPieces = new ChessPieces();

            _iPawnMove             = new PawnMove();
            _allyCoord             = UnitColor.White == unitColor ? chessPieces.WhiteChessPieces.Item2 : chessPieces.BlackChessPieces.Item2;
            _enemyCoord            = UnitColor.White == unitColor ? chessPieces.BlackChessPieces.Item2 : chessPieces.WhiteChessPieces.Item2;
            _enemyKing             = UnitColor.White == unitColor ? chessPieces.BlackChessPieces.Item3 : chessPieces.WhiteChessPieces.Item3;
            _protectEnemyKingMoves = protectEnemyKingMoves;
            _protectAllyKingMoves  = protectAllyKingMoves;
            _potentialMoves        = potentialMoves;
            _unitColor             = unitColor;
        }
Example #22
0
    public BombInfo(CellCtrl triggerModel, float delay, int row, int col, BombCmd bombCmd = BombCmd.None, UnitType curType = UnitType.None, int curSubType = 0, UnitColor curColor = UnitColor.None)
    {
        _triggerModel = triggerModel;
        _row          = row;
        _col          = col;
        _delayTime    = delay;
        _bombCmd      = bombCmd;


        _formType  = curType;
        _subType   = curSubType;
        _formColor = curColor;
    }
Example #23
0
    //Checks whether queen has been placed yet for a given color
    public bool HasQueenBeenPlaced(UnitColor color)
    {
        bool queenPlaced = false;

        foreach (HexCoord hex in occupiedList)
        {
            if (colorDict[hex] == color && typeDict[hex] == UnitType.Queen)
            {
                queenPlaced = true;
            }
        }

        return(queenPlaced);
    }
Example #24
0
        private SQLiteParameter[] GetSqlParameters()
        {
            List <SQLiteParameter> SqlParmColl = new List <SQLiteParameter>();

            try
            {
                SqlParmColl.Add(CommonDB.AddSqlParm("@ID", ID, DbType.Int64));
                SqlParmColl.Add(CommonDB.AddSqlParm("@DisplayID", DisplayID, DbType.Int64));
                SqlParmColl.Add(CommonDB.AddSqlParm("@oIndex", oIndex, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@DlgType", DlgType, DbType.Byte));
                SqlParmColl.Add(CommonDB.AddSqlParm("@DlgIndex", DlgIndex, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Left", Left, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Right", Right, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Top", Top, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Bottom", Bottom, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Format", Format, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Alignment", Alignment, DbType.Byte));
                SqlParmColl.Add(CommonDB.AddSqlParm("@TextValue", TextValue, DbType.String));
                SqlParmColl.Add(CommonDB.AddSqlParm("@TextValueID", TextValueID, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@TextColor", TextColor.ToArgb(), DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@TextBlinking", TextBlinking, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Font", Font, DbType.String));
                SqlParmColl.Add(CommonDB.AddSqlParm("@UnitShow", UnitShow, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@UnitFont", UnitFont, DbType.String));
                SqlParmColl.Add(CommonDB.AddSqlParm("@UnitColor", UnitColor.ToArgb(), DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@UnitText", UnitText, DbType.String));
                SqlParmColl.Add(CommonDB.AddSqlParm("@isfix", isfix, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Orientation", Orientation, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@LastRev", LastRev, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@LockPosition", LockPosition, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@LockEdit", LockEdit, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Layer", Layer, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@FillColor", FillColor, DbType.String));
                SqlParmColl.Add(CommonDB.AddSqlParm("@LineStyle", LineStyle, DbType.String));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Visible", Visible, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Expression", Expression, DbType.String));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Action", Action, DbType.String));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Argument", Argument, DbType.String));
                SqlParmColl.Add(CommonDB.AddSqlParm("@CompiledExp", CompiledExp, DbType.Binary));
                SqlParmColl.Add(CommonDB.AddSqlParm("@validexpression", validexpression, DbType.Boolean));
                return(SqlParmColl.ToArray());
            }
            catch (SQLiteException Exc)
            {
                throw Exc;
            }
        }
Example #25
0
        public Move GetAllMove(UnitColor unitColor, int rowPosition, int colPosition, HashSet <int> allyCoord, HashSet <int> enemyCoord, int enemyKing, HashSet <int> protectEnemyKingMoves, HashSet <int> protectAllyKingMoves, HashSet <int> potentialMoves, bool isInitialized)
        {
            var allPossibleMoves = new AllPawnMoves {
                OneForwardMove      = GetOneForwardMove(unitColor, rowPosition, colPosition, allyCoord, enemyCoord, protectAllyKingMoves, isInitialized),
                TwoForwardMove      = GetTwoForwardMove(unitColor, rowPosition, colPosition, allyCoord, enemyCoord, protectAllyKingMoves, isInitialized),
                OneForwardLeftMove  = GetOneForwardLeftMove(unitColor, rowPosition, colPosition, enemyCoord, enemyKing, protectEnemyKingMoves, protectAllyKingMoves, potentialMoves, isInitialized),
                OneForwardRightMove = GetOneForwardRightMove(unitColor, rowPosition, colPosition, enemyCoord, enemyKing, protectEnemyKingMoves, protectAllyKingMoves, potentialMoves, isInitialized)
            };

            allPossibleMoves.AllMove = new List <int> {
                allPossibleMoves.OneForwardMove,
                allPossibleMoves.TwoForwardMove,
                allPossibleMoves.OneForwardLeftMove,
                allPossibleMoves.OneForwardRightMove
            };
            return(allPossibleMoves);
        }
Example #26
0
    string PieceStringHelper(UnitColor color, UnitType type, int num)
    {
        string str = "";

        //Start with color
        if (color == UnitColor.White)
        {
            str += "w";
        }
        else
        {
            str += "b";
        }

        //Append unit type
        switch (type)
        {
        case UnitType.Ant:
            str += "a";
            break;

        case UnitType.Beetle:
            str += "b";
            break;

        case UnitType.Grasshopper:
            str += "g";
            break;

        case UnitType.Queen:
            str += "q";
            break;

        case UnitType.Spider:
            str += "s";
            break;
        }
        //Append number
        str += num.ToString();

        return(str);
    }
Example #27
0
    //Checks whether either queen of certain color is surrounded
    public bool IsQueenSurrounded(UnitColor color)
    {
        bool queenSurrounded = false;

        Debug.Log("Checking for Queen: " + color.ToString());
        foreach (HexCoord hex in occupiedList)
        {
            if (colorDict[hex] == color && typeDict[hex] == UnitType.Queen)
            {
                int neighborCount = CountOccupiedNeighbors(hex);
                Debug.Log("Queen neighbors: " + neighborCount);
                if (neighborCount == 6)
                {
                    queenSurrounded = true;
                }
                break;
            }
        }
        return(queenSurrounded);
    }
Example #28
0
    // Used when a piece moves to update the lists
    public void MovePiece(HexCoord prevHex, HexCoord newHex, UnitColor color, UnitType type, GameObject obj)
    {
        if (type == UnitType.Beetle)           //If beetle then we need to update lists differently
        {
            if (occupiedList.Contains(newHex)) //If beetle is moving on top of another piece
            {
                beetleDict[newHex]++;          //Add beetle on top
                CoverPieceBelow(obj.transform.position);
                //Don't add beetle to occupied list since hex is already occupied
            }
            else //If new hex is unoccupied then add beetle to occupied list
            {
                occupiedList.Add(newHex);
                colorDict[newHex] = color;
                typeDict[newHex]  = type;
            }
            if (beetleDict[prevHex] > 0)                                                          //If moving a beetle from a stacked position
            {
                beetleDict[prevHex]--;                                                            //Decrement beetle count at previous hex
                UncoverPieceBelow(new Vector3(prevHex.Position().x, prevHex.Position().y, 5.0f)); //Define ray starting point far enough above prev position
            }
            else  //Only remove prevHex from lists if no other piece is at previous position
            {
                occupiedList.Remove(prevHex);
                colorDict.Remove(prevHex);
                typeDict.Remove(prevHex);
            }
        }
        else //If any other move type then change lists and dict as normal;
        {
            occupiedList.Remove(prevHex);
            colorDict.Remove(prevHex);
            typeDict.Remove(prevHex);
            beetleDict.Remove(prevHex);

            occupiedList.Add(newHex);
            colorDict[newHex]  = color;
            typeDict[newHex]   = type;
            beetleDict[newHex] = 0;
        }
    }
Example #29
0
    void Start()
    {
        unitController = GetComponent <UnitController>();
        unitColor      = unitController.unitColor;
        turnScript     = GameObject.Find("BattleManager").GetComponent <TurnManager>();

        targetsRed = GetComponentsInChildren <AttackTargetController>(true)
                     .Select(c => c.gameObject)
                     .Where(go => go.tag == "TargetRed")
                     .ToList();

        targetsBlue = GetComponentsInChildren <AttackTargetController>(true)
                      .Select(c => c.gameObject)
                      .Where(go => go.tag == "TargetBlue")
                      .ToList();

        if (unitColor == UnitColor.Red)
        {
            foreach (GameObject target in targetsBlue)
            {
                target.SetActive(false);
            }

            foreach (GameObject target in targetsRed)
            {
                target.SetActive(true);
            }
        }
        else if (unitColor == UnitColor.Blue)
        {
            foreach (GameObject target in targetsRed)
            {
                target.SetActive(false);
            }

            foreach (GameObject target in targetsBlue)
            {
                target.SetActive(true);
            }
        }
    }
Example #30
0
    //Run eligible placement function to get all outer hexes. Then remove any hexes that neighbor an opposing. Input is the color of the piece that's being placed
    public List <HexCoord> EligiblePlacementByColor(UnitColor color)
    {
        List <HexCoord> eligibleList    = EligiblePlacement();
        List <HexCoord> eligibleListMod = new List <HexCoord>(eligibleList);
        UnitColor       enemyColor;

        if (color == UnitColor.White)
        {
            enemyColor = UnitColor.Black;
        }
        else
        {
            enemyColor = UnitColor.White;
        }

        //Iterate through occupied list and find all neighbors. Add them to the possibly eligible list
        foreach (HexCoord hc in eligibleList)
        {
            foreach (HexCoord adj in hc.Neighbors())  //Check all neighbors of eligible cells
            {
                if (occupiedList.Contains(adj))       //If a neighbor is occupied
                {
                    if (colorDict[adj] == enemyColor) //Check color of any occupied neighbor. If any are enemy color then hex is not eligible
                    {
                        if (eligibleListMod.Contains(hc))
                        {
                            eligibleListMod.Remove(hc);
                        }
                        //break;
                    }
                }
            }
        }
        //Debug.Log(eligibleList.Count);
        return(eligibleListMod);
    }
Example #31
0
        public int GetOneForwardLeftMove(UnitColor unitColor, int rowPosition, int colPosition, HashSet <int> enemyCoord, int enemyKing, HashSet <int> protectEnemyKingMoves, HashSet <int> protectAllyKingMoves, HashSet <int> potentialMoves, bool isInitialized = false)
        {
            var forwardLeft      = unitColor == UnitColor.White ? GetForwardLeftCoordinate(rowPosition, colPosition) : GetBackwardLeftCoordinate(rowPosition, colPosition);
            var originalPosition = rowPosition * 10 + colPosition;
            var possibleMove     = 0;

            if (enemyCoord.Contains(forwardLeft))
            {
                if (forwardLeft == enemyKing)
                {
                    protectEnemyKingMoves.Add(originalPosition);
                }
                possibleMove = forwardLeft;
            }
            //if (allyCoord.Contains(forwardLeft)) {
            //    potentialMoves.Add(forwardLeft);
            //}
            potentialMoves.Add(forwardLeft);
            if (isInitialized || !protectAllyKingMoves.Any())
            {
                return(possibleMove);
            }
            return(!protectAllyKingMoves.Contains(forwardLeft) ? 0 : possibleMove);
        }
Example #32
0
    public int DugoutRegistration(HexCoord currentHex, UnitColor color, UnitType type)
    {
        int num = 1;
        if (color == UnitColor.White)
        {
            foreach (UnitType member in whitePieceList)
            {
                if (member == type)
                {
                    num++;
                }
            }
            whitePieceList.Add(type);
        }
        if (color == UnitColor.Black)
        {
            foreach (UnitType member in blackPieceList)
            {
                if (member == type)
                {
                    num++;
                }
            }
            blackPieceList.Add(type);
        }

        boardList.Add(PieceStringHelper(color, type, num));
        boardDict[PieceStringHelper(color, type, num)] = currentHex;

        return num;
    }
Example #33
0
	IEnumerator SpawnPlayerDelayed(InputDevice device, UnitColor c){

		yield return new WaitForSeconds(spawnAttackerDelay);
		SpawnAttacker(device, c);
	}
Example #34
0
	void SpawnAttacker(InputDevice dev, UnitColor color){
		var spawn = environment.playerSpawns[(int)color].transform.position;
		var attacker = PrefabManager.Instantiate ("AttackingPlayer", spawn).GetComponent<AttackingPlayer>();
		attackerTransforms.Add (attacker.transform);
		attacker.Init(dev, color);
		attacker.health.OnDie += (sender, e) => {
			attackerTransforms.Remove (attacker.transform);
			StartCoroutine(SpawnPlayerDelayed(dev, color));
		};
	}
Example #35
0
    string PieceStringHelper(UnitColor color, UnitType type, int num)
    {
        string str ="";

        //Start with color
        if (color == UnitColor.White)
        {
            str += "w";
        }
        else
        {
            str += "b";
        }

        //Append unit type
        switch (type)
        {
            case UnitType.Ant:
                str += "a";
                break;
            case UnitType.Beetle:
                str += "b";
                break;
            case UnitType.Grasshopper:
                str += "g";
                break;
            case UnitType.Queen:
                str += "q";
                break;
            case UnitType.Spider:
                str += "s";
                break;
        }
        //Append number
        str += num.ToString();

        return str;
    }
Example #36
0
    // Used when a piece first enters the board to populate the type and color lists. Return piece number (if the second white spider then returns 2)
    public void RegisterPiece(HexCoord currentHex, UnitColor color, UnitType type)
    {
        //int index = GetIndex(currentHex);

        //colorList[index] = color;
        //typeList[index] = type;

        occupiedList.Add(currentHex);
        colorDict[currentHex] = color;
        typeDict[currentHex] = type;
        beetleDict[currentHex] = 0; //No beetles on top
    }
Example #37
0
    // Used when a piece moves to update the lists
    public void MovePiece(HexCoord prevHex, HexCoord newHex, UnitColor color, UnitType type, GameObject obj)
    {
        if (type == UnitType.Beetle) //If beetle then we need to update lists differently
        {
            if (occupiedList.Contains(newHex)) //If beetle is moving on top of another piece
            {
                beetleDict[newHex]++;   //Add beetle on top
                CoverPieceBelow(obj.transform.position);
                //Don't add beetle to occupied list since hex is already occupied
            }
            else //If new hex is unoccupied then add beetle to occupied list
            {
                occupiedList.Add(newHex);
                colorDict[newHex] = color;
                typeDict[newHex] = type;
            }
            if (beetleDict[prevHex] > 0)    //If moving a beetle from a stacked position
            {
                beetleDict[prevHex]--;      //Decrement beetle count at previous hex
                UncoverPieceBelow(new Vector3(prevHex.Position().x, prevHex.Position().y, 5.0f)); //Define ray starting point far enough above prev position
            }
            else  //Only remove prevHex from lists if no other piece is at previous position
            {
                occupiedList.Remove(prevHex);
                colorDict.Remove(prevHex);
                typeDict.Remove(prevHex);
            }
        }
        else //If any other move type then change lists and dict as normal;
        {
            occupiedList.Remove(prevHex);
            colorDict.Remove(prevHex);
            typeDict.Remove(prevHex);
            beetleDict.Remove(prevHex);

            occupiedList.Add(newHex);
            colorDict[newHex] = color;
            typeDict[newHex] = type;
            beetleDict[newHex] = 0;
        }
    }
Example #38
0
 //Checks whether either queen of certain color is surrounded
 public bool IsQueenSurrounded(UnitColor color)
 {
     bool queenSurrounded = false;
     Debug.Log("Checking for Queen: " + color.ToString());
     foreach (HexCoord hex in occupiedList)
     {
         if (colorDict[hex] == color && typeDict[hex] == UnitType.Queen)
         {
             int neighborCount = CountOccupiedNeighbors(hex);
             Debug.Log("Queen neighbors: " + neighborCount);
             if (neighborCount == 6)
             {
                 queenSurrounded = true;
             }
             break;
         }
     }
     return queenSurrounded;
 }
Example #39
0
	public static UnitRenderer New(UnitColor color){
		var ans = PrefabManager.Instantiate("UnitRenderer").GetComponent<UnitRenderer>(); 
		ans.Init(color);
		return ans;
	}
Example #40
0
 protected color SolidColor(float player, data data, unit unit)
 {
     return(unit.player == player && fake_selected(data) ? SelectedUnitColor.Get(unit.player) : UnitColor.Get(unit.player));
 }
Example #41
0
 public void DetermineMoveablePieces(UnitColor color)
 {
     if (HasQueenBeenPlaced(color))
     {
         CheckHiveContinuity();      //Populate the validMovePieces list based on maintaining hive continuity
     }
     else
     {
         validMovePieces.Clear();    //If queen hasn't been placed for this color then no pieces can be moved
     }
 }
Example #42
0
 public bool MatchEliminateColor(UnitColor _elimColor)
 {
     if (!IsBombable)
         return false;
     if (Unit.unitColor == _elimColor)
         return true;
     return false;
 }
Example #43
0
    //Run eligible placement function to get all outer hexes. Then remove any hexes that neighbor an opposing. Input is the color of the piece that's being placed
    public List<HexCoord> EligiblePlacementByColor(UnitColor color)
    {
        List<HexCoord> eligibleList = EligiblePlacement();
        List<HexCoord> eligibleListMod = new List<HexCoord>(eligibleList);
        UnitColor enemyColor;
        if (color == UnitColor.White)
            enemyColor = UnitColor.Black;
        else
            enemyColor = UnitColor.White;

        //Iterate through occupied list and find all neighbors. Add them to the possibly eligible list
        foreach (HexCoord hc in eligibleList)
        {
            foreach (HexCoord adj in hc.Neighbors())    //Check all neighbors of eligible cells
            {
                if (occupiedList.Contains(adj))         //If a neighbor is occupied
                {
                    if (colorDict[adj] == enemyColor) //Check color of any occupied neighbor. If any are enemy color then hex is not eligible
                    {
                        if(eligibleListMod.Contains(hc))
                            eligibleListMod.Remove(hc);
                        //break;
                    }
                }

            }
        }
        //Debug.Log(eligibleList.Count);
        return eligibleListMod;
    }
Example #44
0
 public ColorResult(CellCtrl curModel,UnitColor curColor)
     : base(curModel)
 {
     _elimColor = curColor;
 }
Example #45
0
    //Checks whether queen has been placed yet for a given color
    public bool HasQueenBeenPlaced(UnitColor color)
    {
        bool queenPlaced = false;

        foreach (HexCoord hex in occupiedList)
        {
            if (colorDict[hex] == color && typeDict[hex] == UnitType.Queen)
            {
                queenPlaced = true;
            }
        }

        return queenPlaced;
    }
Example #46
0
 public Color getUnitColor(UnitColor p_unitColor)
 {
     return(m_secondaryColorsD[p_unitColor]);
 }
Example #47
0
 public DyeResult(CellCtrl curModel,UnitColor curColor)
     : base(curModel)
 {
     _dyeColor = curColor;
 }