예제 #1
0
    /// <summary>
    /// Function that runs after every frame.
    /// </summary>
    void Update()
    {
        CurrentFrameNumber++;
        Damaged = false;

        if (PreviousMovement != transform.position)
        {
            PreviousMovement = transform.position;
            ActionsInRound.AddAction(new PlayerMovementAction(PreviousMovement, CurrentFrameNumber));
        }

        if (PreviousRotation != transform.rotation)
        {
            PreviousRotation = transform.rotation;
            ActionsInRound.AddAction(new PlayerTurnAction(PreviousRotation, CurrentFrameNumber));
        }
        if (Input.GetMouseButtonDown(0) && isLocalPlayer)
        {
            if (FireSound != null)
            {
                FireSound.Play();
            }

            CmdShoot();

            ActionsInRound.AddAction(new PlayerShootAction(CurrentFrameNumber));
        }

        if (CurrentFrameNumber == 200)
        {
            CloneController.SetActionReader(ActionsInRound);
        }
    }
예제 #2
0
    /// <summary>
    /// Creates a new clone object at the specified starting position, that will use the passed in actions
    /// </summary>
    /// <param name="StartingPosition"></param>
    /// <param name="ActionReader"></param>
    /// <returns></returns>
    private GameObject CreateClone(Vector3 StartingPosition, PlayersActionsInRound ActionReader, Teams Team)
    {
        if (ActionReader == null)
        {
            Debug.Log("Cannot pass in a null starting position or action reader when creating a clone");
            return(null);
        }

        if (ClonePrefab == null)
        {
            Debug.Log("Must set the clone prefab before creating a clone");
            return(null);
        }

        GameObject Clone = (GameObject)Instantiate(ClonePrefab);

        CloneController Controller = Clone.GetComponent <CloneController>();

        if (Controller == null)
        {
            Debug.Log("Cannot create a clone instance using a prefab that doesn't have the clone controller component!");
            return(null);
        }

        Controller.SetStartingPosition(StartingPosition);
        Controller.SetActionReader(ActionReader);
        if (BoundsCheck != null)
        {
            Controller.SetBoundsCheck(BoundsCheck.GetComponent <Collider>());
        }
        else
        {
            Debug.Log("RoundManager doesn't have a set bounds check!");
        }

        Controller.Team = Team;
        Controller.RpcSetGlow(Team);

        return(Clone);
    }