Exemplo n.º 1
0
        public void Tick()
        {
            switch (GetGameState())
            {
            case State.Pregame:
                if (_main.gameInputActive &&
                    Input.IsActionJustPressed("attack_1") &&
                    _playerStarts.Any())
                {
                    PlayerStartNode node = _playerStarts[0];
                    EntPlayer       plyr = _main.factory.SpawnPlayer();
                    _plyrId = plyr.actorId;
                    plyr.GlobalTransform = node.GlobalTransform;
                    SetGameState(State.Gamplay);
                }
                break;

            case State.GameOver:
                uint diff = OS.GetTicksMsec() - _stateTimestamp;
                if (diff < 1000)
                {
                    break;
                }
                if (_main.gameInputActive &&
                    Input.IsActionJustPressed("attack_1"))
                {
                    string cmd = $"map {_mapName}";
                    Console.WriteLine($"Restart map: {cmd}");
                    _main.console.Execute(cmd);
                }
                break;
            }
            if (_debugActorId != NullActorId)
            {
                IActor actor = GetActor(_debugActorId);
                if (actor == null)
                {
                    _debugActorId = NullActorId;
                }
                else
                {
                    _main.SetDebugText(actor.GetActorDebugText());
                }
            }
            else
            {
                _main.SetDebugText(string.Empty);
            }
        }
Exemplo n.º 2
0
    public override void Update()
    {
        base.Update();

        // x button
        bool shieldInput = Input.GetKeyDown("joystick button 2");

        if (shieldInput && _currentShield == null)
        {
            _currentShield = Builder.Instance.Build(Builder.FactoryType.Gameplay, (int)BuilderGameplay.Type.Shield, Vector3.zero, Quaternion.identity, Owner.transform);
            // set Shield
            EntShield ent       = _currentShield.GetComponent <EntShield>();
            EntPlayer entPlayer = Owner.GetComponent <EntPlayer>();
            if (ent != null && entPlayer != null)
            {
                ent.X = entPlayer.X;
                ent.Y = entPlayer.Y;
                ent.Z = entPlayer.Z;
            }
        }
    }
Exemplo n.º 3
0
    public EntPlayer SpawnPlayer()
    {
        EntPlayer plyr = ZqfGodotUtils.CreateInstance <EntPlayer>(Path_EntPlayer, _root);

        return(plyr);
    }