Example #1
0
 void OnWillRenderObject()
 {
     if (CameraEx.IsObjectVisible(Camera.main, GetComponent <SpriteRenderer>()) && !startedCoroutine)
     {
         StartCoroutine(ThrowBone(TimeToSpawn));
     }
 }
Example #2
0
 void OnWillRenderObject()
 {
     if (CameraEx.IsObjectVisible(Camera.main, GetComponent <SpriteRenderer>()) && !IsOnScreen)
     {
         // Camera.main.GetComponent<AudioSource>().
         CanMove    = true;
         CanDamage  = true;
         IsOnScreen = true;
     }
 }
Example #3
0
 void OnWillRenderObject()
 {
     if (CameraEx.IsObjectVisible(Camera.main, GetComponent <SpriteRenderer>()))
     {
         canMove    = true;
         IsOnScreen = true;
     }
     else
     {
         canMove    = false;
         IsOnScreen = false;
     }
 }
    IEnumerator ResetState(float seconds)
    {
        yield return(new WaitForSeconds(seconds));

        if (CameraEx.IsObjectVisible(Camera.main, GetComponent <SpriteRenderer>()))
        {
            if (!hasSetMusic)
            {
                hasSetMusic = true;
            }
            PickNewState();
        }
        StartCoroutine(ResetState(seconds));
    }
        /// <summary>
        /// Update the actions of an ActorController.
        /// </summary>
        /// <param name="controller">The <see cref="ActorController"/> to update.</param>
        private void UpdateMappedActions(ActorController controller)
        {
            if (!this.UpdateActorControllers)
            {
                return;
            }

            if (controller == null)
            {
                return;
            }

            foreach (ActorAction action in controller.Actions.Values)
            {
                Mapping mapping;
                if (!this.Mappings.TryGetValue(action.Name, out mapping))
                {
                    continue;
                }

                var oneAxisMapping = mapping as OneAxisActionMapping;
                var twoAxisMapping = mapping as TwoAxisActionMapping;

                if (oneAxisMapping != null)
                {
                    PlayerAction mappedAction = oneAxisMapping.GetPlayerAction(this.ActiveActionSet);
                    action.Value = new Vector2(mappedAction.Value, 0.0f);
                }

                if (twoAxisMapping != null)
                {
                    PlayerTwoAxisAction mappedAction = twoAxisMapping.GetPlayerAction(this.ActiveActionSet);

                    Vector2 value = mappedAction.Value;

                    if (twoAxisMapping.TransformToCameraLocal && this.Camera != null)
                    {
                        value = CameraEx.TransformWorldToLocalBasedOnCamera(
                            this.Camera,
                            value.ToXZVector3()).ToXZVector2();
                    }

                    action.Value = value;
                }
            }
        }
Example #6
0
 void Install()
 {
     foreach (Transform t in objs)
     {
         ScreenPosSync s      = t.FindComponent <ScreenPosSync>();
         Camera        dstCam = CameraEx.GetCamera(t.gameObject.layer);
         if (s.srcObj == null)
         {
             s.srcObj = srcCam.gameObject.CreateChild(t.name + "_sync").transform;
         }
         // set the src position based on the destination object position
         Vector3 screenPos = dstCam.WorldToScreenPoint(t.position);
         Vector3 srcPos    = srcCam.ScreenToWorldPoint(screenPos);
         float   distance  = Vector3.Distance(dstCam.transform.position, t.position);
         srcPos           += srcCam.transform.forward * distance; // depth
         s.srcObj.position = srcPos;
     }
 }
Example #7
0
        private void SpawnClickEffect(GameObject o)
        {
            if (UICamera.hoveredObject == null)
            {
                return;
            }
            Vector3 clickPos     = UICamera.lastWorldPosition;
            Camera  mainCam      = Camera.main;
            Camera  singletonCam = CameraEx.GetCamera(gameObject.layer);

            if (singletonCam != null && mainCam != null && mainCam != singletonCam)
            {
                clickPos = singletonCam.ScreenToWorldPoint(new Vector3(UICamera.lastEventPosition.x, UICamera.lastEventPosition.y, 0));
            }
            ParticleControl particle = particlePool.GetInstance();

            particle.ignoreTimeScale    = true;
            particle.transform.position = clickPos;
            particle.Play();
        }
    IEnumerator ResetState(float seconds)
    {
        yield return(new WaitForSeconds(seconds));

        if (CameraEx.IsObjectVisible(Camera.main, GetComponent <SpriteRenderer>()))
        {
            hasActivated = true;
            PickNewState();
        }
        else if (hasActivated && attacking)
        {
            var newPos = GameObject.FindGameObjectWithTag("SpawnWall");
            transform.position = newPos.transform.position;
            ready        = false;
            attacking    = false;
            hasActivated = false;
            GetComponent <Rigidbody2D>().velocity       = Vector3.zero;
            GetComponent <CircleCollider2D>().isTrigger = false;
            StopCoroutine(AttackPlayer());
            BossState = 0;
            animator.SetInteger(nameof(BossState), BossState);
        }
        StartCoroutine(ResetState(seconds));
    }
Example #9
0
 // Update is called once per frame
 void Update()
 {
     StartCoroutine(DamageCoroutine());
     isVisible = CameraEx.IsObjectVisible(Camera.main, GetComponent <SpriteRenderer>());
     ScreenWrap();
 }
    bool EnemiesInCamera()
    {
        var enemies = GameObject.FindGameObjectsWithTag("Enemy");

        return(enemies.Any(x => CameraEx.IsObjectVisible(Camera.main, x.GetComponent <Renderer>(), new Vector3(5, 0, 0))));
    }
Example #11
0
 public void Execute(int index)
 {
     results[index] = CameraEx.IsBoundsInCamera(matrix[0], bounds[index]);
 }