//  <<<<<<<<<<<<<<<<< UNITY >>>>>>>>>>>>>>>>>
 void Awake()
 {
     enemyBody = GetComponent <Rigidbody2D>();
     animator  = GetComponent <Animator>();
     Side      = LookingAt.Left;
     canShoot  = canMove = true;
 }
Exemple #2
0
    void SendLookAt(GameObject go)
    {
        //Debug.Log("PlayerInteract.SendLookAt");
        LookingAt lookAt = new LookingAt();

        lookAt.actor = interactorCamera.transform;
        FFMessageBoard <LookingAt> .SendToLocalToAllConnected(lookAt, go);
    }
Exemple #3
0
//  <<<<<<<<<<<<<<<<< MOVEMENT & INTERACTION >>>>>>>>>>>>>>>>>

    void PlayerRun()
    {
        if (canMove)
        {
            float forceX = 0f;
            float vel    = Mathf.Abs(playerBody.velocity.x);
            float xAxis  = Input.GetAxisRaw("Horizontal");

            if (xAxis > 0)
            {
                Side = LookingAt.Right;
                if (vel < maxVelocity)
                {
                    if (grounded)
                    {
                        forceX = speed;
                    }
                    else
                    {
                        forceX = speed * 1.1f;
                    }
                }

                Vector3 scale = transform.localScale;
                scale.x = 0.5f;
                transform.localScale = scale;
                Animator.WalkAnimation(); //Animation
            }
            else if (xAxis < 0)
            {
                Side = LookingAt.Left;
                if (vel < maxVelocity)
                {
                    if (grounded)
                    {
                        forceX = -speed;
                    }
                    else
                    {
                        forceX = -speed * 1.1f;
                    }
                }

                Vector3 temp = transform.localScale;
                temp.x = -0.5f;
                transform.localScale = temp;
                Animator.WalkAnimation(); //Animation
            }
            else
            {
                Animator.ResetIdle(); //Animation
            }
            playerBody.AddForce(new Vector2(forceX, 0));
        }
    }
Exemple #4
0
    void Update()
    {
        //Check if ray hits------------------------------
        RaycastHit hit;
        Ray        ray = cam.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));

        objectHit = null;

        LayerMask layerMask = noItem_LayerMask;

        if (PickUpItem.heldItem)
        {
            layerMask = item_LayerMask;
        }


        if (Physics.Raycast(ray, out hit, 100, layerMask))
        {
            objectHit = hit.transform;
            reticule  = LookingAt.none;

            if (Vector3.Distance(cam.transform.position, objectHit.transform.position) < interactDist)
            {
                //Identify type of object------------------------
                if (objectHit.CompareTag("Interactable"))
                {
                    reticule = LookingAt.interactable;
                }

                //if not holding item, looking at item is valid
                if (!PickUpItem.heldItem && objectHit.CompareTag("Item"))
                {
                    reticule = LookingAt.item;
                }

                //if holding item, looking at location is valid
                if (PickUpItem.heldItem && objectHit.CompareTag("ItemLocation"))
                {
                    reticule = LookingAt.itemLocation;
                }
            }

            //full distance for fire, if it's not fire move along

            else if (objectHit.CompareTag("Fire"))
            {
                reticule = LookingAt.Fire;
            }

            GetInput();
        }
    }
Exemple #5
0
//  <<<<<<<<<<<<<<<<< UNITY >>>>>>>>>>>>>>>>>

    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        isAlive = conscious = canShoot = canHit = canMove = true;

        //SetModel();
        Side = LookingAt.Right;

        playerBody = GetComponent <Rigidbody2D>();
        Animator   = PlayerAnimation.instance;
    }
    private void UpdateLook()
    {
        Animator anim = GetComponent <Animator>();

        if (input.x > 0)
        {
            if (!lastRight)
            {
                lastRight = true;
                GetComponent <SpriteRenderer>().flipX = lastRight;
            }
            anim.SetTrigger("WalkRight");
            lookDir = LookingAt.right;
        }
        else if (input.x < 0)
        {
            if (lastRight)
            {
                lastRight = false;
                GetComponent <SpriteRenderer>().flipX = lastRight;
            }
            anim.SetTrigger("WalkLeft");
            lookDir = LookingAt.left;
        }
        else if (input.y < 0)
        {
            if (lastRight)
            {
                lastRight = false;
                GetComponent <SpriteRenderer>().flipX = lastRight;
            }
            anim.SetTrigger("WalkDown");
            lookDir = LookingAt.bottom;
        }
        else if (input.y > 0)
        {
            if (lastRight)
            {
                lastRight = false;
                GetComponent <SpriteRenderer>().flipX = lastRight;
            }
            anim.SetTrigger("WalkUp");
            lookDir = LookingAt.up;
        }
        else
        {
            anim.SetTrigger("Idle");
        }
    }
    void ChangeDirection()
    {
        Vector3 temp = transform.localScale;

        if (temp.x == 0.5f)
        {
            temp.x = -0.5f;
            Side   = LookingAt.Left;
        }
        else
        {
            temp.x = 0.5f;
            Side   = LookingAt.Right;
        }
        transform.localScale = temp;
    }
Exemple #8
0
 public void Sync(byte[] data, ref int pointerAt)
 {
     lookingAt = (LookingAt)NetUtils.GetNextByte(data, ref pointerAt);
 }