Exemplo n.º 1
0
    void Start()
    {
        vitals    = gameObject.GetComponent <Vitals>();
        inventory = gameObject.GetComponent <Inventory>();

        //General script, all players have this.
        movement = gameObject.GetComponentInParent <PlayerMovement>();

        //Player script, only the local player has this.
        controller = gameObject.GetComponentInParent <PlayerController>();
        tracker    = gameObject.GetComponentInParent <ActionTracker>();
        hud        = gameObject.GetComponent <PlayerHUD>();

        //Shadow script, only the opponent player (shadow) has this.
        replay = gameObject.GetComponentInParent <ActionReplay>();
    }
Exemplo n.º 2
0
        private static ActionResponse ToActionResponse(ActionReplay protoReplay)
        {
            var response = new ActionResponse
            {
                Success = protoReplay.Success,
                Errors  = new List <ActionError>()
            };

            foreach (var error in protoReplay.Errors)
            {
                response.Errors.Add(new ActionError
                {
                    Code        = error.Code,
                    Description = error.Description
                });
            }

            return(response);
        }
Exemplo n.º 3
0
        public static ActionReplay ToActionReplay(this ActionResponse actionResponse)
        {
            var response = new ActionReplay
            {
                Success = actionResponse.Success,
            };

            if (response.Success)
            {
                return(response);
            }

            actionResponse.Errors.ForEach(err =>
            {
                response.Errors.Add(new ActionError
                {
                    Code        = err.Code,
                    Description = err.Description
                });
            });
            return(response);
        }
Exemplo n.º 4
0
        public static ActionResponse ToActionResponse(this ActionReplay actionReplay)
        {
            var response = new ActionResponse
            {
                Success = actionReplay.Success
            };

            if (actionReplay.Success)
            {
                return(response);
            }

            foreach (var error in actionReplay.Errors)
            {
                response.Errors.Add(new Core.Models.UserModels.ActionError
                {
                    Code        = error.Code,
                    Description = error.Description
                });
            }

            return(response);
        }
Exemplo n.º 5
0
    public void play()
    {
        spawner        = new EntitySpawner();
        sessionManager = new SessionManager();
        Session opponentSession;
        Session currentSession;

        if (userAgainst == null)
        {
            opponentSession = null;
        }
        else
        {
            opponentSession = sessionManager.loadOppSession(userAgainst.id, levelChoosen);
        }

        currentSession = sessionManager.create(userLogged, characterChoosen, opponentSession);

        playerObject = spawner.spawnPlayer(currentSession.user, currentSession.character);

        if (opponentSession != null)
        {
            opponentObject = spawner.spawnShadow(opponentSession.user, opponentSession.character);

            if (opponentSession.actions != null)
            {
                ActionReplay replay = opponentObject.GetComponent <ActionReplay>();
                replay.actions = new List <PlayerAction>();
                replay.actions.AddRange(opponentSession.actions);
            }
        }

        StartCoroutine(startMusic());

        state = GameState.INGAME;
    }