/// <summary> Calculates the desired position of the fire based on the 'position' parameter and the Starting Position location. </summary>
    /// <param name="position">The enum value of the desired fire position.</param>
    /// <returns>The desired location as a vector.</returns>
    Vector3 CalcDesiredLocation(FirePosition position)
    {
        // get position of starting location
        Vector3 startPositionLocation = startingPosition.transform.localPosition;

        // initialize the desired location from the Start Position location
        Vector3 desiredLocation = startPositionLocation;

        // make sure y value is same as current location
        desiredLocation.y = _currentLocation.y;

        // work out the desired x value by subtracting the relevane Location Mod from the above desired locaiton
        switch (position)
        {
        case FirePosition.Far:
            desiredLocation.x -= farLocationMod;
            break;

        case FirePosition.Medium:
            desiredLocation.x -= mediumLocationMod;
            break;

        case FirePosition.Close:
            desiredLocation.x -= closeLocationMod;
            break;
        }

        // return the calculated desired location
        return(desiredLocation);
    }
 private static void SyncSightFirePos(FirePosition component, PlayerEntity playerEntity)
 {
     var fireTrans = GetSightFirePos(playerEntity);
     if (fireTrans == null)
     {
         component.SightValid = false;
         component.SightPosition = FixedVector3.zero;
     }
     else
     {
         component.SightValid = true;
         component.SightPosition =fireTrans.position.ShiftedToFixedVector3();
     }
 }
 private static void SyncMuzzleP3Pos(FirePosition component, PlayerEntity playerEntity)
 {
     var pos = GetMuzzleP3Pos(playerEntity);
     if (pos == null)
     {
         component.MuzzleP3Valid = false;
         component.MuzzleP3Position = FixedVector3.zero;
     }
     else
     {
         component.MuzzleP3Valid = true;
         component.MuzzleP3Position = pos.position.ShiftedToFixedVector3();
     }
 }
 public static void SyncToFirePositionComponent(FirePosition component, PlayerEntity playerEntity, IUserCmd cmd)
 {
     SyncSightFirePos(component, playerEntity);
     SyncMuzzleP3Pos(component, playerEntity);
 //    DebugUtil.MyLog( "[seq:{1}]MuzzleP3Position before:{0}",component.MuzzleP3Position,cmd.Seq);
 }
 public static void SyncToFirePositionComponent(FirePosition component, PlayerEntity playerEntity)
 {
     SyncSightFirePos(component, playerEntity);
     SyncMuzzleP3Pos(component, playerEntity);
 }
    /// <summary>
    /// Works out the best position of the fire.
    /// If the player is at full lives, then the fire is as far from the player as possible.
    /// If the player has lost lives, the fire gets as close to the player as posible.
    /// If the player regains lives, the fire moves far away from the player.
    /// If the player's lives have not changed since the last check, the  fire will gradually recede.
    /// </summary>
    /// <param name="creepBack">If creep back is enabled, flame will recede back. If disable, will only update when lives change.</param>
    void CheckLives(bool creepBack)
    {
        // refernce to the player's current lives
        int _currentLives = gameManager.GetComponent <GameManager>().CurrentLives;
        // reference to the player's maxiumim lives
        int _totalLives = gameManager.GetComponent <GameManager>().TotalLives;

        // see if current lives matches total lives.
        if (_currentLives == _totalLives)
        {
            // fire should be far away from the player
            firePosition = FirePosition.Far;
            // update lives to match curretn lives
            _lives = _currentLives;
            // exit funciton
            return;
        }

        // see if the player has lost lives since last checked.
        if (_currentLives < _lives)
        {
            // fire should get really close to the player.
            firePosition = FirePosition.Close;
            // update lives to match curretn lives
            _lives = _currentLives;
            // update the time remaining to the close time
            timeRemaining = closeSeconds;
            // exit funciton
            return;
        }

        // see if the player has gained lives.
        if (_currentLives > _lives)
        {
            // fire should be far away from the player
            firePosition = FirePosition.Far;
            // update lives to match curretn lives
            _lives = _currentLives;
            // exit funciton
            return;
        }

        // player has not gained or lost lives.
        if (_currentLives == _lives && creepBack)
        {
            // increment current ticks.
            timeRemaining -= Time.deltaTime;
            //Debug.Log("Current Ticks is " + currentTicks);
            switch (firePosition)
            {
            case FirePosition.Far:
                // fire remains far away
                break;

            case FirePosition.Medium:
                // check if current ticks equals or exceeds medium ticks value
                if (timeRemaining <= 0)
                {
                    // fire should retract to far away
                    firePosition = FirePosition.Far;
                }
                break;

            case FirePosition.Close:
                // check if current ticks equals or exceeds close ticks value
                if (timeRemaining <= 0)
                {
                    // fire should retract to medium distance
                    firePosition = FirePosition.Medium;
                    // update the time remaining to the medium time
                    timeRemaining = mediumSeconds;
                }
                break;
            }
        }
    }