예제 #1
0
 public void SetReplayPosition(Vector2 position, string trigger, int status)
 {
     // if player has moved and they are not out, move the player and set their direction
     if (_position != position && _status != PieceStatus.OUT)
     {
         float xDiff = position.x - _position.x;
         if (xDiff < 0.0f && _dir != PieceDir.LEFT)
         {
             transform.eulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
             _dir = PieceDir.LEFT;
         }
         else if (xDiff > 0.0f && _dir != PieceDir.RIGHT)
         {
             transform.eulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
             _dir = PieceDir.RIGHT;
         }
         _position = position;
         SetPosition();
     }
     // check if player is out
     if (_status != PieceStatus.OUT && (PieceStatus)status == PieceStatus.OUT)
     {
         //Debug.Log("piece is out!");
         _status   = PieceStatus.OUT;
         enabled   = true;
         _outTimer = OUT_TIME;
         StopAnimation();
     }
     // set animation trigger for Run, Throw, Hit and Default
     if (trigger != "" && _status != PieceStatus.OUT)
     {
         Anim.SetTrigger(trigger);
     }
 }
예제 #2
0
 public void SetDefenseDir(PieceDir dir)
 {
     _dir = dir;
     if (_dir == PieceDir.LEFT)
     {
         transform.eulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
     }
 }
예제 #3
0
    public void Initialize(int id, string name, PieceRole role, Vector2 position, Path currentPath, PieceType pType, Team team)
    {
        //Debug.Log("initialize");
        //_debugStrings = new List<string>();
        SetStandardStats();
        _id          = id;
        _name        = name;
        _role        = role;
        _team        = team;
        _position    = position;
        _currentPath = currentPath;
        if (_currentPath != null)
        {
            GetNextDestination();
        }
        else
        {
            _destination = _position;
        }

        _type      = pType;
        _dir       = PieceDir.NONE;
        _moveState = PieceMoveState.NONE;

        CalculateStatsFromData();

        if (_role == PieceRole.DEFENSE)
        {
            _coolDownTime = 1.0f;
        }
        else
        {
            _coolDownTime = 1.0f;
        }

        _ammo = new AmmoBandelier();
        GenerateRandomAmmo();
        SetPosition();

        switch (_type)
        {
        case PieceType.GENDER_NEUTRAL_1:
            Anim.speed = UnityEngine.Random.Range(0.9f, 0.95f);
            break;

        case PieceType.GENDER_NEUTRAL_2:
            Anim.speed = UnityEngine.Random.Range(1.0f, 1.05f);
            break;

        case PieceType.MALE:
            Anim.speed = UnityEngine.Random.Range(0.95f, 1.0f);
            break;

        case PieceType.FEMALE:
            Anim.speed = UnityEngine.Random.Range(1.05f, 1.1f);
            break;
        }
    }
예제 #4
0
 void SetStandardStats()
 {
     _status           = PieceStatus.NORMAL;
     _pathIndex        = 0;
     _dir              = PieceDir.NONE;
     _moveState        = PieceMoveState.NONE;
     _hasFlag          = false;
     _coolDownTimer    = 0.0f;
     _animationState   = PieceAnimationState.NONE;
     _closestToFlag    = false;
     _downs            = 0;
     _takedowns        = 0;
     _pickups          = 0;
     _balloonsThrown   = 0;
     _distanceWithFlag = 0.0f;
 }
예제 #5
0
        }                               // 估值

        // 顺时针旋转
        public void Turn()
        {
            PieceDir = PieceDir.GetNextDirection();
        }
예제 #6
0
    public void Move()
    {
        if (IsClimbing() && (_animationState == PieceAnimationState.HIT || _animationState == PieceAnimationState.THROW))
        {
            _animationState = PieceAnimationState.CLIMB;
            _lastTrigger    = "Climb";
        }

        if (_role == PieceRole.OFFENSE && (_animationState == PieceAnimationState.RUN || _animationState == PieceAnimationState.NONE || _animationState == PieceAnimationState.CLIMB))
        {
            if (_position != _destination)
            {
                if (CheckClimbPos())
                {
                    if (!IsClimbing())
                    {
                        SetClimbAnimation();
                    }
                }
                else if (!IsRunning())
                {
                    SetRunAnimation();
                }

                float xDiff = _destination.x - _position.x;
                if (xDiff < 0.0f && _dir != PieceDir.LEFT)
                {
                    transform.eulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
                    _dir = PieceDir.LEFT;
                }
                else if (xDiff > 0.0f && _dir != PieceDir.RIGHT)
                {
                    transform.eulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
                    _dir = PieceDir.RIGHT;
                }
            }

            Vector2 oldPosition = _position;
            if (Utilities.CloseEnough(_position, _destination))
            {
                _position = _destination;
                SetPosition();
                _pathIndex++;
                if (_hasFlag)
                {
                    _destination = _team.GetNextHomeDestination(_position);
                }
                else
                {
                    GetNextDestination();
                }
            }
            else
            {
                Vector2 direction = ((_destination - _position).normalized) * (SPEED * _speedCalc);
                _position += direction;
                SetPosition();
            }

            if (_hasFlag)
            {
                AddToDistanceWithFlag(oldPosition, _position);
            }
        }
    }