Beispiel #1
0
    private void FixedUpdate()
    {
        if (!isLocalPlayer)
        {
            return;
        }
        if (!info.EnableAI)
        {
            return;
        }
        if (ContainerManager.IsOpen())
        {
            return;
        }
        if (InputManager.IsFire1Down(true) && info.EnableAI)
        {
            AnimatorStateInfo anim = GetComponent <Animator>().GetCurrentAnimatorStateInfo(0);
            if (currentCombo == -1 && postAttackTimer == null)
            {
                Attack();
            }
            else if ((postAttackTimer != null || (isAttack && anim.length - (anim.normalizedTime * anim.length) < comboTimerError)) && !clickPostAttack)
            {
                clickPostAttack = true;
            }
        }

        GetComponent <Animator>().SetInteger("Attack", isAttack ? currentCombo : -1);
    }
Beispiel #2
0
 public void RpcSendDataToClients(string[] data)
 {
     Deserialize(data.ToList());
     if (ContainerManager.IsOpen(this))
     {
         ContainerManager.UpdateSlots();
     }
 }
Beispiel #3
0
    private void FixedUpdate()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        if (GameSettings.SettingOpenInventoryKey.IsDown())
        {
            if (!ContainerManager.IsOpen())
            {
                ContainerManager.OpenContainer(GameManager.singleton.PlayerInventoryPrefab, GetComponent <IStorage>());
            }
            else if (ContainerManager.IsOpen("Inventory"))
            {
                ContainerManager.CloseContainer();
            }
        }

        if (ContainerManager.IsOpen())
        {
            return;
        }

        if (GameSettings.SettingUseItemKey.IsDown())
        {
            GameObject item = Utils.GetEntityItemOverMouse();
            if (item == null)
            {
                return;
            }

            float distance = Vector3.Distance(item.transform.position, transform.position);
            if (distance > UseItemDistace)
            {
                return;
            }

            RaycastHit2D[] hit = Physics2D.RaycastAll(transform.position,
                                                      (item.transform.position - transform.position).normalized,
                                                      distance, LayerMask.GetMask("Room"));
            if (hit.Any(x => x.collider.name.Equals("Wall")))
            {
                return;
            }

            bool success = GetComponent <IStorage>().AddItemStack(item.GetComponent <EntityItemInfo>().Stack);
            if (success)
            {
                MessageManager.DestroyServerMessage.SendToServer(new NetworkIdentityMessage(item.GetComponent <NetworkIdentity>()));
            }
        }
    }
Beispiel #4
0
    private void FixedUpdate()
    {
        if (!isLocalPlayer)
        {
            return;
        }
        if (!info.EnableAI)
        {
            return;
        }
        if (ContainerManager.IsOpen())
        {
            return;
        }

        int scale = (int)transform.localScale.x;

        transform.Find("NameRender").transform.localScale = new Vector3(scale, 1, 1);
        bool toForward = scale == 1 ? InputManager.HorizontalAxis >= 1 : InputManager.HorizontalAxis <= -1;
        bool toBack    = scale == 1 ? InputManager.HorizontalAxis <= -1 : InputManager.HorizontalAxis >= 1;

        if ((!toForward && !toBack) || (toForward && toBack) || (UnityEngine.Input.GetKey(KeyCode.A) && UnityEngine.Input.GetKey(KeyCode.D)))
        {
            if (info.IsRunBack || info.IsRunForward)
            {
                SetStand();
            }
        }
        else
        {
            SetRun(toForward);
            Move((int)InputManager.HorizontalAxis, info.RunSpeed);
        }

        if (InputManager.IsJumpDown(false) && info.OnGround && Timer.FindTimer("JumpUpper") == null)
        {
            Jump(info.JumpPower / 1.25f);
            Timer.StartNewTimer("JumpUpper", 0.02f, 5, gameObject, timer => {
                if (info.OnGround || InputManager.JumpAxis < 1)
                {
                    timer.Remove();
                }
                else
                {
                    rigidbody2D.AddForce(new Vector2(0, info.JumpPower / 7));
                }
            });
        }

        if (InputManager.IsSitDown(false) && info.OnGround)
        {
            Collider2D[] colliders = new Collider2D[10];
            Physics2D.OverlapCollider(info.GroundTrigger, new ContactFilter2D(), colliders);
            foreach (Collider2D collider in colliders)
            {
                if (collider != null && collider.gameObject.GetComponent <PlatformEffector2D>() != null)
                {
                    collider.gameObject.SetActive(false);
                    Timer.StartNewTimer("RemovePlatform", 0.25f, 1, gameObject,
                                        x => collider.gameObject.SetActive(true));
                }
            }
        }

        Animator anim = GetComponent <Animator>();

        anim.SetBool("RunForward", info.IsRunForward);
        anim.SetBool("RunBack", info.IsRunBack);
        anim.SetBool("Fall", !info.OnGround);
    }