当前位置: 首页>>代码示例>>C#>>正文


C# Move.getDirection方法代码示例

本文整理汇总了C#中Move.getDirection方法的典型用法代码示例。如果您正苦于以下问题:C# Move.getDirection方法的具体用法?C# Move.getDirection怎么用?C# Move.getDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Move的用法示例。


在下文中一共展示了Move.getDirection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AttemptMove

    /// <summary>
    /// Attempts to execute the specified move.  If there is something in the way, will not change position or facing, but will return false.
    /// In Entity, this does not handle fighting.  Override it to incorporate that behavior.  
    /// </summary>
    /// <returns><c>true</c>, if the move was successfully executed, <c>false</c> otherwise.</returns>
    /// <param name="move">The move to execute.</param>
    protected virtual bool AttemptMove(Move move)
    {
        //does nothing on these cases anyway,
        //but we want to prevent it assigning them as facings.
        switch (move)
        {
        case Move.Fight:
        case Move.None:
            return false;
        }

        //Debug.Log(gameObject.name + " attempts moving " + move);

        //find the destination tile
        Vector2 moveDir = move.getDirection();
        int destX = x + (int)moveDir.x;
        int destY = y + (int)moveDir.y;

        if(GridManager.instance.isPassable(destX, destY))
        {
            //moves the entity if there is no obstacle
            //Debug.Log ("moved");
            x = destX;
            y = destY;
            Vector2 dest = GridManager.getTransformPosition(x, y);
            moveDest = new Vector3(dest.x, dest.y, -1);
        //			transform.position = new Vector3(dest.x, dest.y, -1);
            isMoving = true;
            facing = move;

            animator.Play("Walk");

            return true;
        }
        else
        {
            return false;
        }
    }
开发者ID:karatesaul,项目名称:BarCrawl,代码行数:45,代码来源:Entity.cs

示例2: AttemptMove

    protected override bool AttemptMove(Move move)
    {
        if (move == lastMove)
        {
            combo++;
            //Debug.Log(combo + "x COMBO!");
        }
        else
        {
            lastMove = move;
            combo = fullCombo / 4;
            //Debug.Log("Combo reset to " + combo);
        }
        fullCombo++;

        if (move == Move.Heal) {
            health += healAmount + (combo * healIncrease);
            //1 and 2 are 5 less than before; 3 is the same; 4 and higher are more.
            if(health > maxHealth)
                health = maxHealth;
            Instantiate(healingEffect, transform.position + new Vector3(0, 0, .5f), Quaternion.identity);
            return true;
        }
        else
        {
            bool success = false;
            if(move == Move.Fight && combo > 2)
            {
                //Debug.Log("AoE triggered!");

                //play an obscenity

                //i.e. the fourth or later punch in a row
                List<Entity> closeEntities = GridManager.instance.getEntitiesInRect(x - 2, x + 2, y + 2, y - 2);

                foreach(Entity entity in closeEntities)
                {
                    if(entity != null)
                    {
                        if(entity.gameObject.tag == foeTag)
                        {
                            entity.takeDamage(10);

                            success = true;
                        }
                    }
                }

                animator.Play("AttackDown");
                shakyCam = shakeTime;
                Instantiate(aoeEffect, transform.position, Quaternion.identity);
                audioSources[2].volume = PlayerPrefs.GetFloat(InGameMenu.effectVolKey);
                audioSources[2].Play();

                if (Random.Range(0, 5) == 0)
                    SFXManager.PlayerVoice();
                return success;
            }

            success = base.AttemptMove (move);
            if(success)
                return true;
            //else

            if(move.isDirectional())
            {
                facing = move;

                //find the destination tile
                Vector2 moveDir = move.getDirection();
                int destX = x + (int)moveDir.x;
                int destY = y + (int)moveDir.y;

                Entity target = GridManager.instance.getTarget(destX, destY);

                if(target != null)
                {
                    if(target.gameObject.tag == foeTag)
                    {
                        //a fightable enemy!
                        //deal it some damage.

                        target.takeDamage(blunderDamage);
                        animator.Play ("AttackLeft");

                        //Debug.Log("Player blunders into " + target.gameObject.name + ", dealing " + blunderDamage + " damage!  " + target.health + " health remains.");

                        target.currentRed = 100;

                        return true;
                    }
                }

                return false;
            }
            else if(move == Move.Fight && combo > 0)
            {
                //Debug.Log("Ranged attempt triggered");

                //try again with range.
//.........这里部分代码省略.........
开发者ID:karatesaul,项目名称:BarCrawl,代码行数:101,代码来源:PlayerCharacter.cs


注:本文中的Move.getDirection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。