Exemplo n.º 1
0
 // Start is called before the first frame update
 void Awake()
 {
     playerInputComponent = GetComponent <PlayerInput>();
     playerChecks         = GetComponent <PlayerChecks>();
     rb    = GetComponent <Rigidbody2D>();
     aimer = GameObject.Find("Gadget");
 }
Exemplo n.º 2
0
 void DustSpawner()
 {
     //This function calls all the other functions to generate dust
     if (Random.Range(0, 1000) >= 900 && rb.velocity.x != 0 && PlayerInfo.isGrounded)
     {
         PlayerChecks.GenerateParticle(dust);
     }
     SpeedBackDust();
 }
Exemplo n.º 3
0
        public async void Load(string ID, bool LoadNearPlayer = false)
        {
            if (Context.Player == null)
            {
                Context.Respond("This is a player only command!");
                return;
            }

            PlayerChecks User = new PlayerChecks(Context);
            await HangarCommandSystem.RunTaskAsync(() => User.LoadGrid(ID, LoadNearPlayer), Context);
        }
Exemplo n.º 4
0
 private void GroundedUpdate()
 {
     if (rb.velocity.y == 0)
     {
         PlayerInfo.isGrounded = PlayerChecks.IsGrounded(PlayerInfo.colliderCenter, PlayerInfo.colliderExtents);
     }
     else
     {
         PlayerInfo.isGrounded = false;
     }
 }
Exemplo n.º 5
0
        public async void Info(string ID = "")
        {
            if (Context.Player == null)
            {
                Context.Respond("This is a player only command!");
                return;
            }

            PlayerChecks User = new PlayerChecks(Context);
            await HangarCommandSystem.RunTaskAsync(() => User.DetailedInfo(ID), Context);
        }
Exemplo n.º 6
0
    void SpeedBackDust()
    {
        currentVelocity = rb.velocity.x;
        float difference = currentVelocity - lastVelocity;

        if ((difference == -maxVelocityDifference || difference == maxVelocityDifference) && PlayerInfo.isGrounded)
        {
            PlayerChecks.GenerateParticle(dust);
        }
        lastVelocity = currentVelocity;
    }
Exemplo n.º 7
0
 public void CallDash(float xRaw, float yRaw)
 {
     if (xRaw == 0 && yRaw == 0)
     {
         DashMove(PlayerInfo.facing, yRaw);
     }
     else
     {
         DashMove(xRaw, yRaw);
     }
     PlayerChecks.GenerateParticle(dashParticles);
 }
Exemplo n.º 8
0
        public async void SaveGrid()
        {
            if (Context.Player == null)
            {
                Context.Respond("This is a player only command!");
                return;
            }


            PlayerChecks User = new PlayerChecks(Context);
            await HangarCommandSystem.RunTaskAsync(() => User.SaveGrid(), Context);
        }
Exemplo n.º 9
0
    void Update()
    {
        jumpTime += Time.fixedDeltaTime;
        if (Input.GetKeyDown(KeyCode.Space))
        {
            jumpTime = 0;
        }

        if (jumpTime <= minJumpTime && PlayerInfo.isGrounded && PlayerInfo.canJump)
        {
            rb.velocity = new Vector2(rb.velocity.x, jumpForce);
            jumpTime    = minJumpTime;
            PlayerChecks.GenerateParticle(particles);
            PlayerInfo.isJumping = true;
        }
    }
Exemplo n.º 10
0
        public async void SellGrid(int ID, long price, string description)
        {
            if (!Hangar.Config.PluginEnabled)
            {
                return;
            }

            if (Context.Player == null || !Hangar.Config.GridMarketEnabled)
            {
                Context.Respond("This is a player only command!");
                return;
            }


            PlayerChecks User = new PlayerChecks(Context);
            await HangarCommandSystem.RunTaskAsync(() => User.SellGrid(ID, price, description), Context);
        }
Exemplo n.º 11
0
    void WalkAnim()
    {
        float inputX      = Input.GetAxisRaw("Horizontal");
        bool  isColliding = PlayerChecks.WallCollision(PlayerInfo.colliderCenter, PlayerInfo.colliderExtents, inputX);
        bool  needFlip;

        PlayerInfo.facing = (int)inputX;
        animator.SetFloat("Speed", Mathf.Abs(inputX));
        if (PlayerInfo.isColliding && PlayerInfo.isGrounded && Input.GetAxisRaw("Horizontal") != 0)
        {
            AnimPlay("Pushing");
        }
        else if (PlayerInfo.isColliding)
        {
            animator.SetFloat("Speed", 0);
        }
        needFlip             = PlayerInfo.facing == 1 ? false : true;
        spriteRenderer.flipX = needFlip;
    }
Exemplo n.º 12
0
 public async void ListGrids()
 {
     PlayerChecks User = new PlayerChecks(Context);
     await HangarCommandSystem.RunTaskAsync(() => User.ListGrids(), Context);
 }
Exemplo n.º 13
0
        public void Remove(int ID)
        {
            PlayerChecks User = new PlayerChecks(Context);

            HangarCommandSystem.RunTask(delegate { User.RemoveGrid(ID); }, Context.Player?.SteamUserId);
        }
Exemplo n.º 14
0
        public void Load(int ID, bool LoadNearPlayer = false)
        {
            PlayerChecks User = new PlayerChecks(Context);

            HangarCommandSystem.RunTask(delegate { User.LoadGrid(ID, LoadNearPlayer); }, Context.Player?.SteamUserId);
        }
Exemplo n.º 15
0
        public void ListGrids()
        {
            PlayerChecks User = new PlayerChecks(Context);

            HangarCommandSystem.RunTask(delegate { User.ListGrids(); }, Context.Player?.SteamUserId);
        }
Exemplo n.º 16
0
        public void Info(int ID = 0)
        {
            PlayerChecks User = new PlayerChecks(Context);

            HangarCommandSystem.RunTask(delegate { User.DetailedInfo(ID); }, Context.Player?.SteamUserId);
        }
 // Start is called before the first frame update
 void Awake()
 {
     playerChecks           = GetComponent <PlayerChecks>();
     animCharacterComponent = GetComponentInChildren <AnimationComponent>();
     rb = GetComponent <Rigidbody2D>();
 }
Exemplo n.º 18
0
        private static void ReceivePacket(ushort HandlerId, byte[] Data, ulong SteamID, bool FromServer)
        {
            // Only consider trusted server messages, i.e. from Nexus itself, not untrusted player messages.
            if (!FromServer)
            {
                return;
            }

            NexusHangarMessage msg;

            try
            {
                msg = MyAPIGateway.Utilities.SerializeFromBinary <NexusHangarMessage>(Data);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Invalid Nexus cross-server message for Quantum Hangar");
                return;
            }

            switch (msg.Type)
            {
            case NexusHangarMessageType.Chat:
                var chat = new ScriptedChatMsg()
                {
                    Author = msg.Sender,
                    Text   = msg.Response,
                    Font   = MyFontEnum.White,
                    Color  = msg.Color,
                    Target = msg.ChatIdentityID
                };
                MyMultiplayerBase.SendScriptedChatMessage(ref chat);
                return;

            case NexusHangarMessageType.SendGPS:
                gpsSender.SendGps(msg.Position, msg.Name, msg.EntityID);
                return;

            case NexusHangarMessageType.LoadGrid:
                var chatOverNexus = new Chat((text, color, sender) =>
                {
                    NexusHangarMessage m = new NexusHangarMessage
                    {
                        Type       = NexusHangarMessageType.Chat,
                        IdentityID = msg.IdentityID,
                        Response   = text,
                        Color      = color,
                        Sender     = sender,
                    };
                    API.SendMessageToServer(msg.ServerID, MyAPIGateway.Utilities.SerializeToBinary <NexusHangarMessage>(m));
                });

                var gpsOverNexus = new GpsSender((position, name, entityID) =>
                {
                    NexusHangarMessage m = new NexusHangarMessage
                    {
                        Type     = NexusHangarMessageType.SendGPS,
                        Name     = name,
                        Position = position,
                        EntityID = entityID,
                    };
                    API.SendMessageToServer(msg.ServerID, MyAPIGateway.Utilities.SerializeToBinary <NexusHangarMessage>(m));
                });

                PlayerChecks User = new PlayerChecks(chatOverNexus, gpsOverNexus, msg.SteamID, msg.IdentityID, msg.PlayerPosition);


                User.LoadGrid(msg.LoadGridID.ToString(), msg.LoadNearPlayer);
                return;
            }

            Log.Error("Invalid Nexus cross-server message for Quantum Hangar (unrecognized type: " + msg.Type + ")");
        }