コード例 #1
0
    public void PickUpPlank(GameObject playerRef)
    {
        //pick it up (done by player)

        //tell plank what player to look at
        this.gameObject.GetComponent <SnapTest2>().player = playerRef;

        //get player who placed me
        playerWhoPlacedMe = playerRef.GetComponent <PlayerController>();



        //StartCoroutine(plankAnim.PickUpPlankAnim());

        /*
         * //destroy rigidbody
         * if (this.gameObject.GetComponent<Rigidbody>() != null)
         * {
         *  Destroy(this.gameObject.GetComponent<Rigidbody>());
         * }
         */

        //held
        plankState = PlankState.held;
    }
コード例 #2
0
    public void PlacingPlank()
    {
        print(this.gameObject + " Placing");

        //don't let plank hit players
        SetToNotHitPlayers();

        //turn on artificial gravity
        snapRef.GravitySwitch(true);

        //turn on collider
        this.gameObject.GetComponent <Collider>().enabled = true;

        //make trigger
        this.gameObject.GetComponent <Collider>().isTrigger = true;

        //reduce size of collider
        //make collider full sized
        this.gameObject.GetComponent <BoxCollider>().size   = new Vector3(0.308f, 1, 1);
        this.gameObject.GetComponent <BoxCollider>().center = new Vector3(0.345f, 0, 0);

        this.gameObject.GetComponent <Rigidbody>().isKinematic = true;

        //unparent
        if (this.gameObject.transform.parent != null)
        {
            //unparent
            this.gameObject.transform.parent = null;
        }

        plankState = PlankState.beingplaced;
    }
コード例 #3
0
    public void PlacingPlank()
    {
        //turn on collider
        this.gameObject.GetComponent <Collider>().enabled = true;

        //make trigger
        this.gameObject.GetComponent <Collider>().isTrigger = true;

        this.gameObject.GetComponent <Rigidbody>().isKinematic = true;

        //turn on artificial gravity
        snapRef.GravitySwitch(true);

        //make rotation -5 on z axis
        Vector3 tempEuler = this.gameObject.transform.localEulerAngles;

        tempEuler.z = -5f;
        this.gameObject.transform.localEulerAngles = tempEuler;

        //unparent
        if (this.gameObject.transform.parent != null)
        {
            //unparent
            this.gameObject.transform.parent = null;
        }

        plankState = PlankState.beingplaced;
    }
コード例 #4
0
    public void DropPlank()
    {
        print(this.gameObject + " Dropped");
        //turn on collider
        this.gameObject.GetComponent <Collider>().enabled = true;

        //not trigger
        this.gameObject.GetComponent <Collider>().isTrigger = false;

        //make collider full sized
        this.gameObject.GetComponent <BoxCollider>().size   = new Vector3(1, 1, 1);
        this.gameObject.GetComponent <BoxCollider>().center = Vector3.zero;


        //turn off artificial gravity
        snapRef.GravitySwitch(false);

        //make hitable by players
        SetToHitPlayers();

        /*
         * //if no rigidbody add one
         * if (this.gameObject.GetComponent<Rigidbody>() == null)
         * {
         *  this.gameObject.AddComponent<Rigidbody>();
         * }
         */
        this.gameObject.GetComponent <Rigidbody>().isKinematic = false;

        plankState = PlankState.dropped;
    }
コード例 #5
0
    public void PickUpPlank(GameObject playerRef)
    {
        print(this.gameObject + " Picked Up");
        //pick it up (done by player)

        //tell plank what player to look at
        this.gameObject.GetComponent <SnapTest2>().player = playerRef;

        //get player who placed me
        playerWhoPlacedMe = playerRef.GetComponent <PlayerController>();

        //set to not hit players
        SetToNotHitPlayers(); //turn on then off when board slamming

        /*
         * //destroy rigidbody
         * if (this.gameObject.GetComponent<Rigidbody>() != null)
         * {
         *  Destroy(this.gameObject.GetComponent<Rigidbody>());
         * }
         */
        this.gameObject.GetComponent <Rigidbody>().isKinematic = true;

        //turn off collider
        this.gameObject.GetComponent <Collider>().enabled = false;


        //held
        plankState = PlankState.held;
    }
コード例 #6
0
 public void PickUpSpawn()
 {
     //print("pick up");
     plankState = PlankState.spawned;
     //add this to game manager list
     GameManager.S.planksInScene.Add(this);
     Init();
 }
コード例 #7
0
    public void PlacePlank()
    {
        print(this.gameObject + "Placed");

        /*
         * //get rid of rigidbody
         * if (this.gameObject.GetComponent<Rigidbody>() != null)
         * {
         *  Destroy(this.gameObject.GetComponent<Rigidbody>());
         * }
         */
        if (this.gameObject.GetComponent <Rigidbody>() != null)
        {
            this.gameObject.GetComponent <Rigidbody>().isKinematic = true;
        }


        this.gameObject.GetComponent <Collider>().isTrigger = false;


        //turn off artifical gravity (stop from moving)
        snapRef.GravitySwitch(false);

        //this fixes boards snapping to wrong places
        //if z mildly rotated make it 0
        if (this.gameObject.transform.eulerAngles.z != 0)
        {
            Vector3 temp;
            temp   = this.gameObject.transform.eulerAngles;
            temp.z = 0;
            this.gameObject.transform.eulerAngles = temp;
        }

        //turn on collider
        this.gameObject.GetComponent <Collider>().enabled = true;
        //make trigger
        this.gameObject.GetComponent <Collider>().isTrigger = false;

        //make collider full sized
        this.gameObject.GetComponent <BoxCollider>().size   = new Vector3(1, 1, 1);
        this.gameObject.GetComponent <BoxCollider>().center = Vector3.zero;

        //give them points
        if (playerWhoPlacedMe != null)
        {
            playerWhoPlacedMe.GetComponent <Points>().AddPointsForBoardPlace();

            /*playerWhoPlacedMe.GetComponent<FlashyPoints>().ShowPointsGained(playerWhoPlacedMe.transform.position,
             *  playerWhoPlacedMe.GetComponent<Points>().pointsForBoardPlace);*/
        }

        plankState = PlankState.placed;
    }
コード例 #8
0
 /// <summary>
 /// Рисем портрет данного игрока на данной позиции.
 /// </summary>
 private void DrawPortrait(Player player, Vector2 position,
                           PlankState plankState)
 {
     switch (plankState)
     {
     case PlankState.Active:
         screenManager.SpriteBatch.Draw(player.Portrait,
                                        position, Color.White);
         break;
         //case PlankState.InActive:
         //    screenManager.SpriteBatch.Draw(player.InactivePortraitTexture,
         //        position, Color.White);
         // break;
         //case PlankState.CantUse:
         //    screenManager.SpriteBatch.Draw(player.UnselectablePortraitTexture,
         //        position, Color.White);
         //    break;
     }
 }
コード例 #9
0
        /// <summary>
        /// Draw the portrait of the given player at the given position.
        /// </summary>
        private void DrawPortrait(Player player, Vector2 position,
                                  PlankState plankState)
        {
            switch (plankState)
            {
            case PlankState.Active:
                screenManager.SpriteBatch.Draw(player.ActivePortraitTexture, position, null, Color.White, 0f,
                                               Vector2.Zero, ScaledVector2.DrawFactor, SpriteEffects.None, 0f);
                break;

            case PlankState.InActive:
                screenManager.SpriteBatch.Draw(player.InactivePortraitTexture, position, null, Color.White, 0f,
                                               Vector2.Zero, ScaledVector2.DrawFactor, SpriteEffects.None, 0f);
                break;

            case PlankState.CantUse:
                screenManager.SpriteBatch.Draw(player.UnselectablePortraitTexture, position, null, Color.White, 0f,
                                               Vector2.Zero, ScaledVector2.DrawFactor, SpriteEffects.None, 0f);
                break;
            }
        }
コード例 #10
0
    public void DropPlank()
    {
        //print(this.gameObject + " Dropped");
        //turn on collider

        //to stop it from falling through floor
        this.gameObject.transform.position += new Vector3(0, .2f, 0);

        this.gameObject.GetComponent <Collider>().enabled = true;

        //not trigger
        this.gameObject.GetComponent <Collider>().isTrigger = false;

        //make collider full sized
        this.gameObject.GetComponent <BoxCollider>().size   = new Vector3(1, 1, 1);
        this.gameObject.GetComponent <BoxCollider>().center = Vector3.zero;


        //turn off artificial gravity
        snapRef.GravitySwitch(false);

        this.gameObject.GetComponent <Rigidbody>().isKinematic = false;

        SetToHitPlayers();



        //StartCoroutine(DropDelaySetToHitPlayers());

        /*
         * //if no rigidbody add one
         * if (this.gameObject.GetComponent<Rigidbody>() == null)
         * {
         *  this.gameObject.AddComponent<Rigidbody>();
         * }
         */

        plankState = PlankState.dropped;
    }
コード例 #11
0
ファイル: HudScreen.cs プロジェクト: slmjy/MonogameShooter
 /// <summary>
 /// Рисем портрет данного игрока на данной позиции.
 /// </summary>
 private void DrawPortrait(Player player, Vector2 position,
     PlankState plankState)
 {
     switch (plankState)
     {
         case PlankState.Active:
             screenManager.SpriteBatch.Draw(player.Portrait,
                 position, Color.White);
             break;
         //case PlankState.InActive:
         //    screenManager.SpriteBatch.Draw(player.InactivePortraitTexture,
         //        position, Color.White);
            // break;
         //case PlankState.CantUse:
         //    screenManager.SpriteBatch.Draw(player.UnselectablePortraitTexture,
         //        position, Color.White);
         //    break;
     }
 }
コード例 #12
0
ファイル: HudScreen.cs プロジェクト: slmjy/MonogameShooter
        /// <summary>
        /// Рисуем детали о игроке
        /// </summary>
        /// <param name="playerIndex">Показатель детлей о игроке, которые нужно отрисовать</param>
        /// <param name="position">Место где прорисовать</param>
        private void DrawCombatPlayerDetails(Player player, Vector2 position)
        {
            SpriteBatch spriteBatch = screenManager.SpriteBatch;

            PlankState plankState = new PlankState();
            bool isPortraitActive = false;
            bool isCharDead = false;
            Color color;

            portraitPosition.X = position.X + 7f;
            portraitPosition.Y = position.Y + 7f;

            namePosition.X = position.X + 84f;
            namePosition.Y = position.Y + 12f;

            levelPosition.X = position.X + 84f;
            levelPosition.Y = position.Y + 39f;

            detailPosition.X = position.X + 25f;
            detailPosition.Y = position.Y + 66f;

            position.X -= 2;
            position.Y -= 4;

            //if (player.IsTurnTaken)
            //{
            //    plankState = PlankState.CantUse;

            //    isPortraitActive = false;
            //}
            //else
            //{
            //    plankState = PlankState.InActive;

            //    isPortraitActive = true;
            //}
            //движоок
            //if (((CombatEngine.HighlightedCombatant == player) && !player.IsTurnTaken) ||
            //   (CombatEngine.PrimaryTargetedCombatant == player) ||
            //  (CombatEngine.SecondaryTargetedCombatants.Contains(player)))
            // {
            // plankState = PlankState.Active;
            //}

            //if (player.IsDeadOrDying)
            //{
            //    isCharDead = true;
            //    isPortraitActive = false;
            //    plankState = PlankState.CantUse;
            //}

            // Рисует информационную плитку
            if (plankState == PlankState.Active)
            {
                color = activeNameColor;

                spriteBatch.Draw(activeCharInfoTexture, position, Color.White);

                // Рисует скобки
                // if ((CombatEngine.HighlightedCombatant == player) && !player.IsTurnTaken)
                // {
                //      spriteBatch.Draw(selectionBracketTexture, position, Color.White);
                //  }

                //if (isPortraitActive &&
                //    (CombatEngine.HighlightedCombatant == player) &&
                //    (CombatEngine.HighlightedCombatant.CombatAction == null) &&
                //    !CombatEngine.IsDelaying)
                //{
                //        position.X += activeCharInfoTexture.Width / 2;
                //        position.X -= combatPopupTexture.Width / 2;
                //        position.Y -= combatPopupTexture.Height;
                //        // Рисует действие
                //        DrawActionsMenu(position);
                //    }
                //}
                //else if (plankState == PlankState.InActive)
                //{
                //    color = inActiveNameColor;
                //    spriteBatch.Draw(inActiveCharInfoTexture, position, Color.White);
                //}
                //else
                //{
                //    color = Color.Black;
                //    spriteBatch.Draw(cantUseCharInfoTexture, position, Color.White);
                //}

                if (isCharDead)
                {
                    spriteBatch.Draw(deadPortraitTexture, portraitPosition, Color.White);
                }
                else
                {
                    // Рисует портрет игрока
                    DrawPortrait(player, portraitPosition, plankState);
                }

                // Рисует имя игрока
                spriteBatch.DrawString(HudFont,
                    player.Name,
                    namePosition, color);

                color = Color.Black;
                // РИсует детали о игроке
                spriteBatch.DrawString(HudFont,
                    "Lvl: " + player.Level,
                    levelPosition, color);

                spriteBatch.DrawString(HudFont,
                    "HP: " + player.HP +
                    "/" + player.HPLeft,
                    detailPosition, color);

                detailPosition.Y += 30f;
                spriteBatch.DrawString(HudFont,
                    "SP: " + player.SP +
                    "/" + player.SPLeft,
                    detailPosition, color);
            }
        }
コード例 #13
0
    public void PlacePlank()
    {
        //print(this.gameObject + "Placed");

        /*
         * //get rid of rigidbody
         * if (this.gameObject.GetComponent<Rigidbody>() != null)
         * {
         *  Destroy(this.gameObject.GetComponent<Rigidbody>());
         * }
         */

        //CHECK TO MAKE SURE NOT BEING PLACED ON GROUND (needs fixing)


        RaycastHit hitInfo;

        //raycast down to make sure not on ground
        if (Physics.Raycast(this.gameObject.transform.position, Vector3.down, out hitInfo, .1f))
        {
            //print("hit " + hitInfo.collider.gameObject.name);

            //make sure not too soon after plank initially created

            //print("Early plank " + earlyPlank);

            if (hitInfo.collider.gameObject.GetComponent <PlankManager>() == null && hitInfo.collider.gameObject.GetComponent <PlayerController>() == null &&
                !earlyPlank)
            {
                //print("earlyplank place drop because middle raycast down hit " + hitInfo.collider.gameObject.name);

                //if it is drop it and return
                DropPlank();
                //gets 0 points
                //GameManager.S.player1.GetComponent<FlashyPoints>().ShowPointsGained(transform.position, 0);
                return;
            }
        }


        if (this.gameObject.GetComponent <Rigidbody>() != null)
        {
            this.gameObject.GetComponent <Rigidbody>().isKinematic = true;
        }


        this.gameObject.GetComponent <Collider>().isTrigger = false;


        //turn off artifical gravity (stop from moving)
        snapRef.GravitySwitch(false);

        //this fixes boards snapping to wrong places
        //if z mildly rotated make it 0
        if (this.gameObject.transform.eulerAngles.z != 0)
        {
            Vector3 temp;
            temp   = this.gameObject.transform.eulerAngles;
            temp.z = 0;
            this.gameObject.transform.eulerAngles = temp;
        }

        //turn on collider
        this.gameObject.GetComponent <Collider>().enabled = true;
        //make trigger
        this.gameObject.GetComponent <Collider>().isTrigger = false;

        //make collider full sized
        this.gameObject.GetComponent <BoxCollider>().size   = new Vector3(1, 1, 1);
        this.gameObject.GetComponent <BoxCollider>().center = Vector3.zero;

        //give them points
        if (playerWhoPlacedMe != null)
        {
            playerWhoPlacedMe.GetComponent <Points>().AddPointsForBoardPlace();
            //show
            GameManager.S.player1.GetComponent <FlashyPoints>().ShowPointsGained(transform.position, GameManager.S.player1.GetComponent <Points>().pointsForBoardPlace);

            /*playerWhoPlacedMe.GetComponent<FlashyPoints>().ShowPointsGained(playerWhoPlacedMe.transform.position,
             *  playerWhoPlacedMe.GetComponent<Points>().pointsForBoardPlace);*/
        }

        plankState = PlankState.placed;
    }
コード例 #14
0
ファイル: Hud.cs プロジェクト: Vintharas/WP7projects
 /// <summary>
 /// Draw the portrait of the given player at the given position.
 /// </summary>
 private void DrawPortrait(Player player, Vector2 position, 
     PlankState plankState)
 {
     switch (plankState)
     {
         case PlankState.Active:
             screenManager.SpriteBatch.Draw(player.ActivePortraitTexture, position,null, Color.White,0f,
                 Vector2.Zero, ScaledVector2.DrawFactor, SpriteEffects.None, 0f);
             break;
         case PlankState.InActive:
             screenManager.SpriteBatch.Draw(player.InactivePortraitTexture, position,null, Color.White,0f,
                 Vector2.Zero, ScaledVector2.DrawFactor, SpriteEffects.None, 0f);
             break;
         case PlankState.CantUse:
             screenManager.SpriteBatch.Draw(player.UnselectablePortraitTexture, position,null, Color.White,0f,
                 Vector2.Zero, ScaledVector2.DrawFactor, SpriteEffects.None, 0f);
             break;
     }
 }
コード例 #15
0
        /// <summary>
        /// Рисуем детали о игроке
        /// </summary>
        /// <param name="playerIndex">Показатель детлей о игроке, которые нужно отрисовать</param>
        /// <param name="position">Место где прорисовать</param>
        private void DrawCombatPlayerDetails(Player player, Vector2 position)
        {
            SpriteBatch spriteBatch = screenManager.SpriteBatch;

            PlankState plankState       = new PlankState();
            bool       isPortraitActive = false;
            bool       isCharDead       = false;
            Color      color;

            portraitPosition.X = position.X + 7f;
            portraitPosition.Y = position.Y + 7f;

            namePosition.X = position.X + 84f;
            namePosition.Y = position.Y + 12f;

            levelPosition.X = position.X + 84f;
            levelPosition.Y = position.Y + 39f;

            detailPosition.X = position.X + 25f;
            detailPosition.Y = position.Y + 66f;

            position.X -= 2;
            position.Y -= 4;

            //if (player.IsTurnTaken)
            //{
            //    plankState = PlankState.CantUse;

            //    isPortraitActive = false;
            //}
            //else
            //{
            //    plankState = PlankState.InActive;

            //    isPortraitActive = true;
            //}
            //движоок
            //if (((CombatEngine.HighlightedCombatant == player) && !player.IsTurnTaken) ||
            //   (CombatEngine.PrimaryTargetedCombatant == player) ||
            //  (CombatEngine.SecondaryTargetedCombatants.Contains(player)))
            // {
            // plankState = PlankState.Active;
            //}

            //if (player.IsDeadOrDying)
            //{
            //    isCharDead = true;
            //    isPortraitActive = false;
            //    plankState = PlankState.CantUse;
            //}

            // Рисует информационную плитку
            if (plankState == PlankState.Active)
            {
                color = activeNameColor;

                spriteBatch.Draw(activeCharInfoTexture, position, Color.White);

                // Рисует скобки
                // if ((CombatEngine.HighlightedCombatant == player) && !player.IsTurnTaken)
                // {
                //      spriteBatch.Draw(selectionBracketTexture, position, Color.White);
                //  }

                //if (isPortraitActive &&
                //    (CombatEngine.HighlightedCombatant == player) &&
                //    (CombatEngine.HighlightedCombatant.CombatAction == null) &&
                //    !CombatEngine.IsDelaying)
                //{
                //        position.X += activeCharInfoTexture.Width / 2;
                //        position.X -= combatPopupTexture.Width / 2;
                //        position.Y -= combatPopupTexture.Height;
                //        // Рисует действие
                //        DrawActionsMenu(position);
                //    }
                //}
                //else if (plankState == PlankState.InActive)
                //{
                //    color = inActiveNameColor;
                //    spriteBatch.Draw(inActiveCharInfoTexture, position, Color.White);
                //}
                //else
                //{
                //    color = Color.Black;
                //    spriteBatch.Draw(cantUseCharInfoTexture, position, Color.White);
                //}

                if (isCharDead)
                {
                    spriteBatch.Draw(deadPortraitTexture, portraitPosition, Color.White);
                }
                else
                {
                    // Рисует портрет игрока
                    DrawPortrait(player, portraitPosition, plankState);
                }

                // Рисует имя игрока
                spriteBatch.DrawString(HudFont,
                                       player.Name,
                                       namePosition, color);

                color = Color.Black;
                // РИсует детали о игроке
                spriteBatch.DrawString(HudFont,
                                       "Lvl: " + player.Level,
                                       levelPosition, color);

                spriteBatch.DrawString(HudFont,
                                       "HP: " + player.HP +
                                       "/" + player.HPLeft,
                                       detailPosition, color);

                detailPosition.Y += 30f;
                spriteBatch.DrawString(HudFont,
                                       "SP: " + player.SP +
                                       "/" + player.SPLeft,
                                       detailPosition, color);
            }
        }