private void OnPlayerBannerLoaded(string name, GameObject go, object callbackData)
 {
     Player.Side side = (Player.Side)((int)callbackData);
     if (go == null)
     {
         UnityEngine.Debug.LogError(string.Format("Gameplay.OnPlayerBannerLoaded() - FAILED to load \"{0}\" side={1}", name, side.ToString()));
     }
     else if (this.IsHandlingNetworkProblem())
     {
         UnityEngine.Object.Destroy(go);
     }
     else if (UniversalInputManager.UsePhoneUI != null)
     {
         NameBannerGamePlayPhone component = go.GetComponent <NameBannerGamePlayPhone>();
         if (component != null)
         {
             this.m_nameBannerGamePlayPhone = component;
             this.m_nameBannerGamePlayPhone.SetPlayerSide(side);
         }
         else
         {
             NameBanner item = go.GetComponent <NameBanner>();
             item.SetPlayerSide(side);
             this.m_nameBanners.Add(item);
         }
     }
     else
     {
         NameBanner banner2 = go.GetComponent <NameBanner>();
         banner2.SetPlayerSide(side);
         this.m_nameBanners.Add(banner2);
     }
 }
Esempio n. 2
0
        public void RotateAim(Aim aim, Player.Side side)
        {
            float rightThumbstickY = currentGamePadState.ThumbSticks.Right.Y;
            float rightThumbstickX = currentGamePadState.ThumbSticks.Right.X;

            if ((rightThumbstickX != 0 || rightThumbstickY != 0))
            {
                float thumbstickAngle = 0;

                float thumbstickAngleAngleInDegrees = 0;

                thumbstickAngle = (float)Math.Atan2(rightThumbstickY, rightThumbstickX);

                thumbstickAngleAngleInDegrees = (float)aim.RadianToDegree(thumbstickAngle);

                if (side == Player.Side.Left)
                {
                    if (thumbstickAngleAngleInDegrees >= 0)
                    {
                        thumbstickAngleAngleInDegrees = 90 - (thumbstickAngleAngleInDegrees - 90);
                    }
                    else
                    {
                        thumbstickAngleAngleInDegrees = -90 + ((thumbstickAngleAngleInDegrees + 90) * -1);
                    }
                }

                aim.Rotate(thumbstickAngleAngleInDegrees);
            }

            aim.angle = aim.DegreeToRadian(aim.angleInDegrees);
        }
Esempio n. 3
0
        //enum InputSelected { None, KeyboardOne, KeyboardTwo, GamePadOne, GamePadTwo, GamePadThree, GamePadFour }

        public Selection(Texture2D selectionBoxTexture, Texture2D characterTexture, int characterWidth, int characterHeight,
                         Rectangle destination, Vector2 position, Player.Side side, string playerID)
        {
            this.position            = position;
            this.selectionBoxTexture = selectionBoxTexture;
            this.characterTexture    = characterTexture;
            this.selectionBoxDestinationRectangle = destination;
            this.side             = side;
            this.playerID         = playerID;
            maxCharacters         = 4;
            character             = Character.Dwarf;
            currentCharacterFrame = (int)character;
            selectionKind         = SelectionKind.InputSelection;
            //inputSelected = InputSelected.None;
            text                = "Press Start";
            textSize            = Game1.font24.MeasureString(text);
            characterName       = character.ToString();
            characterNameSize   = Game1.font36.MeasureString(characterName);
            showTextElapsedTime = 0;
            showText            = true;

            selectionBoxSourceRectangle   = new Rectangle(0, 0, boxWidth, boxHeight);
            characterDestinationRectangle = new Rectangle(destination.X, destination.Y + (destination.Y / 2), characterWidth, characterHeight);
            characterSourceRectangle      = new Rectangle((int)(currentCharacterFrame * characterSelectionWidth), 0, characterSelectionWidth, characterSelectionHeight);
        }
Esempio n. 4
0
        public void Update(GameTime gameTime, Player.Side side)
        {
            elapsedTime += (int)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (elapsedTime > millisecondsToChangeFrame)
            {
                currentFrame++;

                if (currentFrame > lastFrame)
                {
                    currentFrame = 0;
                }

                rectangle.X = currentFrame * frameWidth;

                elapsedTime = 0;
            }

            if (side == Player.Side.Right)
            {
                angle    = angle * -1f;
                origin.X = 0;
                effect   = SpriteEffects.None;
            }
            else if (side == Player.Side.Left)
            {
                origin.X = frameWidth;
                effect   = SpriteEffects.FlipHorizontally;
            }
        }
Esempio n. 5
0
        public void ChangePosition(Skinny skinny, float angle, Player.Side direction)
        {
            disappearancePositionX = (int)skinny.positionX;
            disappearancePositionY = (int)skinny.positionY;

            float initialPositionX = (int)skinny.positionX;
            float initialPositionY = (int)skinny.positionY;

            if (direction == Player.Side.Right)
            {
                skinny.positionX += (float)((distance) * Math.Cos(angle * -1));
            }
            else
            {
                skinny.positionX += -((float)((distance) * Math.Cos(angle * -1)));
            }

            skinny.positionY += (float)((distance) * Math.Sin(angle * -1));

            skinny.positionX = MathHelper.Clamp(skinny.positionX, 0, Game1.screenWidth - (skinny.width) - 1);
            skinny.positionY = MathHelper.Clamp(skinny.positionY, 0, Game1.screenHeight - (skinny.height) - 1);

            skinny.AdjustPositionInCaseOfTilesIntersection(initialPositionX, initialPositionY);

            appearanceSmokePositionX = (int)skinny.positionX - ((appearanceSmoke.frameWidth - skinny.width) / 2);
            appearanceSmokePositionY = (int)skinny.positionY - ((appearanceSmoke.frameHeight - skinny.height) / 2);
        }
Esempio n. 6
0
 public void SetPlayerSide(Player.Side side)
 {
     this.m_playerSide = side;
     this.UpdateAnchor();
     base.StartCoroutine(this.UpdateName());
     base.StartCoroutine(this.UpdateUnknownName());
 }
Esempio n. 7
0
    public void RpcCreateUnit(string UnitName, int ID, Player.Side side)
    {
        //Jeder Client
        Debug.Log("RpcCreateUnit: " + UnitName + " , " + side, this);
        UnitData data = null;

        for (int i = 0; i < UnitDataAsset.I.UnitLibrary.Length; i++)
        {
            if (UnitDataAsset.I.UnitLibrary[i].Name == UnitName)
            {
                data = UnitDataAsset.I.UnitLibrary[i];
                break;
            }
        }

        if (data == null)
        {
            Debug.LogError("No UnitData found: " + UnitName, this);
            return;
        }

        var gObj = new GameObject("Unit");

        gObj.layer = 10;
        var unit = gObj.AddComponent <Unit>();

        unit.UnitID = ID;
        unit.Side   = side;
        unit.InitData(data);
        var rigid = gObj.AddComponent <Rigidbody>();

        rigid.isKinematic = true;

        Field field = null;

        for (int i = 0; i < GameLogic.I.FieldManager.SpawnableFields.Length; i++)
        {
            if (GameLogic.I.FieldManager.SpawnableFields[i].PlayerSide == side)
            {
                field = GameLogic.I.FieldManager.SpawnableFields[i];
                break;
            }
        }

        if (field != null)
        {
            field.Units.Add(unit);
            unit.CurrentField = field.gameObject;
            unit.UpdateStackPosition();
            GameLogic.I.Units.Add(unit);
            //player.Units.Add(unit);
            unit.transform.position = field.transform.position;
        }
        else
        {
            Destroy(unit.gameObject);
        }
    }
Esempio n. 8
0
        public void SetTeleport(Skinny skinny, float angle, Player.Side direction)
        {
            ChangePosition(skinny, angle, direction);

            skinnyTeleporting            = true;
            drawDisappearance            = true;
            drawAppearanceSmoke          = true;
            disappearance.currentFrame   = 0;
            appearanceSmoke.currentFrame = 0;
        }
Esempio n. 9
0
        public void PrepareToThrow(float positionX, float positionY, float angle, Player.Side direction)
        {
            this.positionX = positionX;

            this.positionY = positionY;

            this.angle = angle;

            SetIncrementValues(direction);
        }
Esempio n. 10
0
 // return true if the piece is opponents
 private bool isOpponentPiece(Player.Side current, Type opponentPiece)
 {
     if (current == Player.Side.BLACK && (opponentPiece == Type.WHITE || opponentPiece == Type.WHITE_KING))
     {
         return(true);
     }
     if (current == Player.Side.WHITE && (opponentPiece == Type.BLACK || opponentPiece == Type.BLACK_KING))
     {
         return(true);
     }
     return(false);
 }
Esempio n. 11
0
        public void SetIncrementValues(Player.Side direction)
        {
            if (direction == Player.Side.Right)
            {
                IncrementX = (float)((force) * Math.Cos(angle * -1));
            }
            else
            {
                IncrementX = -((float)((force) * Math.Cos(angle * -1)));
            }

            IncrementY = (float)((force) * Math.Sin(angle * -1));
        }
Esempio n. 12
0
        public void RotateAim(Aim aim, Player.Side side)
        {
            if (currentKeyboardState.IsKeyDown(upKey))
            {
                aim.Rotate((int)1);
            }
            else if (currentKeyboardState.IsKeyDown(downKey))
            {
                aim.Rotate((int)-1);
            }

            aim.angle = aim.DegreeToRadian(aim.angleInDegrees);
        }
Esempio n. 13
0
    private bool isMovingOwnPiece(int row, int col, Player.Side side)
    {
        Type pieceType = getPiece(row, col);

        if (side == Player.Side.BLACK && pieceType != Type.BLACK && pieceType != Type.BLACK_KING)
        {
            return(false);
        }
        else if (side == Player.Side.WHITE && pieceType != Type.WHITE && pieceType != Type.WHITE_KING)
        {
            return(false);
        }
        return(true);
    }
Esempio n. 14
0
    private void OnFatigueActorLoaded(string actorName, GameObject actorObject, object callbackData)
    {
        if (actorObject == null)
        {
            UnityEngine.Debug.LogWarning(string.Format("FatigueSpellController.OnFatigueActorLoaded() - FAILED to load actor \"{0}\"", actorName));
            this.DoFinishFatigue();
        }
        else
        {
            Actor component = actorObject.GetComponent <Actor>();
            if (component == null)
            {
                UnityEngine.Debug.LogWarning(string.Format("FatigueSpellController.OnFatigueActorLoaded() - ERROR actor \"{0}\" has no Actor component", actorName));
                this.DoFinishFatigue();
            }
            else
            {
                Player.Side controllerSide = base.GetSource().GetControllerSide();
                bool        flag           = controllerSide == Player.Side.FRIENDLY;
                this.m_fatigueActor = component;
                UberText nameText = this.m_fatigueActor.GetNameText();
                if (nameText != null)
                {
                    nameText.Text = GameStrings.Get("GAMEPLAY_FATIGUE_TITLE");
                }
                UberText powersText = this.m_fatigueActor.GetPowersText();
                if (powersText != null)
                {
                    object[] objArray1 = new object[] { this.m_fatigueTagChange.Value };
                    powersText.Text = GameStrings.Format("GAMEPLAY_FATIGUE_TEXT", objArray1);
                }
                component.SetCardBackSideOverride(new Player.Side?(controllerSide));
                component.UpdateCardBack();
                ZoneDeck deck = !flag?GameState.Get().GetOpposingSidePlayer().GetDeckZone() : GameState.Get().GetFriendlySidePlayer().GetDeckZone();

                deck.DoFatigueGlow();
                this.m_fatigueActor.transform.localEulerAngles = FATIGUE_ACTOR_INITIAL_LOCAL_ROTATION;
                this.m_fatigueActor.transform.localScale       = FATIGUE_ACTOR_START_SCALE;
                this.m_fatigueActor.transform.position         = deck.transform.position;
                Vector3[] vectorArray = new Vector3[] { this.m_fatigueActor.transform.position, new Vector3(this.m_fatigueActor.transform.position.x, this.m_fatigueActor.transform.position.y + 3.6f, this.m_fatigueActor.transform.position.z), Board.Get().FindBone("FatigueCardBone").position };
                object[]  args        = new object[] { "path", vectorArray, "time", 1.2f, "easetype", iTween.EaseType.easeInSineOutExpo };
                iTween.MoveTo(this.m_fatigueActor.gameObject, iTween.Hash(args));
                object[] objArray3 = new object[] { "rotation", FATIGUE_ACTOR_FINAL_LOCAL_ROTATION, "time", 1.2f, "delay", 0.15f };
                iTween.RotateTo(this.m_fatigueActor.gameObject, iTween.Hash(objArray3));
                iTween.ScaleTo(this.m_fatigueActor.gameObject, FATIGUE_ACTOR_FINAL_SCALE, 1f);
                base.StartCoroutine(this.WaitThenFinishFatigue(0.8f));
            }
        }
    }
Esempio n. 15
0
    public void CmdCreateUnit(string UnitName, Player.Side side)
    {
        //Server
        //Debug.LogWarning("CmdCreateInfantry: " + side, this);
        //Generate ID
        //string ID = lastUnitID++;
        RpcCreateUnit(UnitName, lastUnitID++, side);

        /*
         * var tmp = CreateUnit(UnitName, lastUnitID++, side);
         * if (tmp)
         *  NetworkServer.Spawn(tmp.gameObject);
         * else
         *  Debug.LogError("Could not create Unit!", this);
         */
    }
Esempio n. 16
0
        public void RotateAim(Aim aim, Player.Side side)
        {
            if (currentMouseState.Position != previousMouseState.Position)
            {
                if (currentMouseState.Position.Y < aim.mouseAimArea.Y - (aim.mouseAimArea.Height / 2))
                {
                    aim.Rotate((int)1);
                }
                else if (currentMouseState.Position.Y > aim.mouseAimArea.Y - (aim.mouseAimArea.Height / 2))
                {
                    aim.Rotate((int)-1);
                }
            }

            aim.angle = aim.DegreeToRadian(aim.angleInDegrees);
        }
    public static List <Zone> FindZonesFromTag(Spell spell, SpellZoneTag zoneTag, SpellPlayerSide spellSide)
    {
        if (ZoneMgr.Get() != null)
        {
            if (spellSide == SpellPlayerSide.NEUTRAL)
            {
                return(null);
            }
            if (spellSide == SpellPlayerSide.BOTH)
            {
                return(FindZonesFromTag(zoneTag));
            }
            Player.Side side = ConvertSpellSideToPlayerSide(spell, spellSide);
            switch (zoneTag)
            {
            case SpellZoneTag.PLAY:
                return(ZoneMgr.Get().FindZonesOfType <Zone, ZonePlay>(side));

            case SpellZoneTag.HERO:
                return(ZoneMgr.Get().FindZonesOfType <Zone, ZoneHero>(side));

            case SpellZoneTag.HERO_POWER:
                return(ZoneMgr.Get().FindZonesOfType <Zone, ZoneHeroPower>(side));

            case SpellZoneTag.WEAPON:
                return(ZoneMgr.Get().FindZonesOfType <Zone, ZoneWeapon>(side));

            case SpellZoneTag.DECK:
                return(ZoneMgr.Get().FindZonesOfType <Zone, ZoneDeck>(side));

            case SpellZoneTag.HAND:
                return(ZoneMgr.Get().FindZonesOfType <Zone, ZoneHand>(side));

            case SpellZoneTag.GRAVEYARD:
                return(ZoneMgr.Get().FindZonesOfType <Zone, ZoneGraveyard>(side));

            case SpellZoneTag.SECRET:
                return(ZoneMgr.Get().FindZonesOfType <Zone, ZoneSecret>(side));
            }
            Debug.LogWarning(string.Format("SpellUtils.FindZonesFromTag() - Unhandled zoneTag {0}. spellSide={1} playerSide={2}", zoneTag, spellSide, side));
        }
        return(null);
    }
Esempio n. 18
0
    public List <Move> getAllValidMoves(Player.Side side)
    {
        Type normal = side == Player.Side.BLACK ? Type.BLACK : Type.WHITE;
        Type king   = side == Player.Side.BLACK ? Type.BLACK_KING : Type.WHITE_KING;

        List <Move> possibleMoves = new List <Move>();

        for (int i = 0; i < SIZE; i++)
        {
            for (int j = 0; j < SIZE; j++)
            {
                Type t = getPiece(i, j);
                if (t == normal || t == king)
                {
                    possibleMoves.AddRange(getValidMoves(i, j, side)); //---------------------------------*AddAll
                }
            }
        }


        return(possibleMoves);
    }
Esempio n. 19
0
    public List <Move> getValidSkipMoves(int row, int col, Player.Side side)
    {
        List <Move> move  = new List <Move>();
        Vector2     start = new Vector2(row, col);

        List <Vector2> possibilities = new List <Vector2>();

        if (side == Player.Side.WHITE && getPiece(row, col) == Type.WHITE)
        {
            possibilities.Add(new Vector2(row + 2, col + 2));
            possibilities.Add(new Vector2(row + 2, col - 2));
        }
        else if (side == Player.Side.BLACK && getPiece(row, col) == Type.BLACK)
        {
            possibilities.Add(new Vector2(row - 2, col + 2));
            possibilities.Add(new Vector2(row - 2, col - 2));
        }
        else if (getPiece(row, col) == Type.BLACK_KING || getPiece(row, col) == Type.WHITE_KING)
        {
            possibilities.Add(new Vector2(row + 2, col + 2));
            possibilities.Add(new Vector2(row + 2, col - 2));
            possibilities.Add(new Vector2(row - 2, col + 2));
            possibilities.Add(new Vector2(row - 2, col - 2));
        }

        for (int i = 0; i < possibilities.Count; i++)
        {
            Vector2 temp = possibilities[i];//------------------------*.get(i);
            Move    m    = new Move(start, temp);
            if (temp.x < SIZE && temp.x >= 0 && temp.y < SIZE && temp.y >= 0 && getPiece((int)temp.x, (int)temp.y) == Type.EMPTY &&
                isOpponentPiece(side, getPiece(findMidSquare(m))))
            {
                move.Add(m);
            }
        }

        //System.out.println("Skip moves: " + move);
        return(move);
    }
Esempio n. 20
0
 // Use this for initialization
 void Start()
 {
     if (name.Equals("Left Collider"))
     {
         side = Player.Side.Left;
     }
     else if (name.Equals("Right Collider"))
     {
         side = Player.Side.Right;
     }
     else if (name.Equals("Top Collider"))
     {
         side = Player.Side.Top;
     }
     else if (name.Equals("Bottom Collider"))
     {
         side = Player.Side.Bottom;
     }
     else
     {
         side = Player.Side.None;
     }
 }
    private static Card FindBestTargetCard(Spell spell)
    {
        Card sourceCard = spell.GetSourceCard();

        if (sourceCard != null)
        {
            Player controller = sourceCard.GetEntity().GetController();
            if (controller == null)
            {
                return(spell.GetVisualTargetCard());
            }
            Player.Side       side          = controller.GetSide();
            List <GameObject> visualTargets = spell.GetVisualTargets();
            for (int i = 0; i < visualTargets.Count; i++)
            {
                Card component = visualTargets[i].GetComponent <Card>();
                if ((component != null) && (component.GetEntity().GetController().GetSide() != side))
                {
                    return(component);
                }
            }
        }
        return(spell.GetVisualTargetCard());
    }
Esempio n. 22
0
 public void Draw(SpriteBatch spriteBatch, Player.Side side)
 {
     spriteBatch.Draw(spritesheet, position, rectangle, Color.White, angle, origin, 1.0f, effect, 1);
 }
Esempio n. 23
0
 public void SetPlayerSide(Player.Side side)
 {
     object[] objArray1 = new object[] { side };
     base.method_8("SetPlayerSide", objArray1);
 }
Esempio n. 24
0
    // returns true if move successful
    public Decision makeMove(Move move, Player.Side side)
    {
        if (move.getEnd() == null && move.getStart() == null)
        {
            return(Decision.GAME_ENDED);
        }
        Vector2 start    = move.getStart();
        int     startRow = (int)start.x;
        int     startCol = (int)start.y;
        Vector2 end      = move.getEnd();
        int     endRow   = (int)end.x;
        int     endCol   = (int)end.y;

        //can only move own piece and not empty space
        if (!isMovingOwnPiece(startRow, startCol, side) || getPiece(startRow, startCol) == Type.EMPTY)
        {
            return(Decision.FAILED_MOVING_INVALID_PIECE);
        }

        List <Move> possibleMoves = getValidMoves(startRow, startCol, side);
        //System.out.println(possibleMoves);

        Type currType = getPiece(startRow, startCol);

        if (possibleMoves.Contains(move))
        {
            bool jumpMove = false;
            //if it contains move then it is either 1 move or 1 jump
            if (startRow + 1 == endRow || startRow - 1 == endRow)
            {
                board[startRow, startCol] = Type.EMPTY;
                board[endRow, endCol]     = currType;
            }
            else
            {
                jumpMove = true;
                board[startRow, startCol] = Type.EMPTY;
                board[endRow, endCol]     = currType;
                Vector2 mid = findMidSquare(move);

                Type middle = getPiece(mid);
                if (middle == Type.BLACK)
                {
                    numBlackNormalPieces--;
                }
                else if (middle == Type.BLACK_KING)
                {
                    numBlackKingPieces--;
                }
                else if (middle == Type.WHITE)
                {
                    numWhiteNormalPieces--;
                }
                else if (middle == Type.WHITE_KING)
                {
                    numWhiteKingPieces--;
                }
                board[(int)mid.x, (int)mid.y] = Type.EMPTY;
            }

            if (endRow == 0 && side == Player.Side.BLACK)
            {
                board[endRow, endCol] = Type.BLACK_KING;
                numBlackNormalPieces--;
                numBlackKingPieces++;
            }

            else if (endRow == SIZE - 1 && side == Player.Side.WHITE)
            {
                board[endRow, endCol] = Type.WHITE_KING;
                numWhiteNormalPieces--;
                numWhiteKingPieces++;
            }
            if (jumpMove)
            {
                List <Move> additional = getValidSkipMoves(endRow, endCol, side);
                if (additional == null) // additional.isEmpty
                {
                    return(Decision.COMPLETED);
                }
                return(Decision.ADDITIONAL_MOVE);
            }
            return(Decision.COMPLETED);
        }
        else
        {
            return(Decision.FAILED_INVALID_DESTINATION);
        }
    }
Esempio n. 25
0
    public List <Move> getValidMoves(int row, int col, Player.Side side)
    {
        Type    type       = board[row, col];
        Vector2 startPoint = new Vector2(row, col);

        if (type == Type.EMPTY)
        {
            throw new System.ArgumentException(); //----------------------------*IllegalArgumentException();
        }
        List <Move> moves = new List <Move>();

        //4 possible moves, 2 if not king
        if (type == Type.WHITE || type == Type.BLACK)
        {
            //2 possible moves
            int rowChange = type == Type.WHITE ? 1 : -1;

            int newRow = row + rowChange;
            if (newRow >= 0 || newRow < SIZE)
            {
                int newCol = col + 1;
                if (newCol < SIZE && getPiece(newRow, newCol) == Type.EMPTY)
                {
                    moves.Add(new Move(startPoint, new Vector2(newRow, newCol)));
                }
                newCol = col - 1;
                if (newCol >= 0 && getPiece(newRow, newCol) == Type.EMPTY)
                {
                    moves.Add(new Move(startPoint, new Vector2(newRow, newCol)));
                }
            }
        }
        //must be king
        else
        {
            //4 possible moves

            int newRow = row + 1;
            if (newRow < SIZE)
            {
                int newCol = col + 1;
                if (newCol < SIZE && getPiece(newRow, newCol) == Type.EMPTY)
                {
                    moves.Add(new Move(startPoint, new Vector2(newRow, newCol)));
                }
                newCol = col - 1;
                if (newCol >= 0 && getPiece(newRow, newCol) == Type.EMPTY)
                {
                    moves.Add(new Move(startPoint, new Vector2(newRow, newCol)));
                }
            }
            newRow = row - 1;
            if (newRow >= 0)
            {
                int newCol = col + 1;
                if (newCol < SIZE && getPiece(newRow, newCol) == Type.EMPTY)
                {
                    moves.Add(new Move(startPoint, new Vector2(newRow, newCol)));
                }
                newCol = col - 1;
                if (newCol >= 0 && getPiece(newRow, newCol) == Type.EMPTY)
                {
                    moves.Add(new Move(startPoint, new Vector2(newRow, newCol)));
                }
            }
        }

        moves.AddRange(getValidSkipMoves(row, col, side));
        return(moves);
    }