Example #1
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            UnityEngine.EventSystems.PointerEventData eventData = new UnityEngine.EventSystems.PointerEventData(null);
            eventData.position = Input.mousePosition;

            List <UnityEngine.EventSystems.RaycastResult> results = new List <UnityEngine.EventSystems.RaycastResult>();
            raycaster.Raycast(eventData, results);
            foreach (var result in results)
            {
                if (result.gameObject.layer == LayerMask.NameToLayer("Octo"))
                {
                    Wander wander = result.gameObject.GetComponent <Wander>();
                    if (wander != null)
                    {
                        wander.OnPressed(Input.mousePosition);
                    }
                    else
                    {
                        CapturedOcto captured = result.gameObject.GetComponent <CapturedOcto>();
                        if (captured != null)
                        {
                            captured.OnPressed();
                        }
                    }
                }
                else if (result.gameObject.layer == LayerMask.NameToLayer("CapturedOcto"))
                {
                    CapturedOcto captured = result.gameObject.GetComponent <CapturedOcto>();
                    captured.OnPressed();
                }
            }
        }
    }
Example #2
0
    void SetUpLevel()
    {
        GameManager.Instance.ClearCapturedOctos();
        int amountOfCapturedOctos = currenLevelData.CapturedOctos.Length;

        for (int i = 0; i < amountOfCapturedOctos; ++i)
        {
            GameObject   go = Instantiate(capturedOctoPrefab, transform);
            CapturedOcto co = go.GetComponent <CapturedOcto>();
            co.Init(currenLevelData.CapturedOctos[i].KeysNeeded);
            RectTransform rt = go.GetComponent <RectTransform>();
            rt.anchorMin        = currenLevelData.CapturedOctos[i].Anchor;
            rt.anchorMax        = currenLevelData.CapturedOctos[i].Anchor;
            rt.anchoredPosition = currenLevelData.CapturedOctos[i].Position;
            GameManager.Instance.AddCapturedOcto(rt);
        }
        GameManager.Instance.SharkScoreGoal = currenLevelData.amounToDefeat;
        GameManager.Instance.SetGoalAmount(amountOfCapturedOctos);
    }
Example #3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        bool isCollidingWithGoal = collision.gameObject.layer == LayerMask.NameToLayer("Goal");

        if (isCollidingWithGoal == true && myCollider.isTrigger == false)
        {
            if (myHasCollidedWithCapturedOcto == true || myIsCaptruedOctoFreed == true)
            {
                myWander.WalkSpeed *= 3f;                //Camera.main.pixelHeight / 4;
                //GameManager.Instance.AddScore(1);
                myParticles.SetActive(true);
                Destroy(gameObject, 1f);
            }
            //else
            //{

            //	var pos = collision.bounds.ClosestPoint(transform.position);
            //	Debug.Log(pos);

            //	//collision.GetContacts(new Collider2D[] { myCollider });
            //	//foreach (ContactPoint2D cp in collision.)
            //	//{
            //	//	myWalkDirection = Vector2.Reflect(myWalkDirection, cp.normal);
            //	//	return;
            //	//}
            //}
        }
        else if (collision.gameObject.layer == LayerMask.NameToLayer("KillZone"))
        {
            //GameManager.Instance.AddSharkScore(1);
            Destroy(gameObject, 1f);
        }
        else if (collision.gameObject.layer == LayerMask.NameToLayer("CapturedOcto"))
        {
            CapturedOcto captured = collision.GetComponent <CapturedOcto>();
            captured.UseKey();
            myWander.SetTarget(GameManager.Instance.TopGoal);
            myHasCollidedWithCapturedOcto = true;
            //myWander.SetTarget();
        }
    }