Exemplo n.º 1
0
        private void CreateCloud()
        {
            if (playerCP.CurrentCloudPoint.Value < createCloudusedccp)
            {
                return;
            }
            else
            {
                playerCP.ChangeCP(-createCloudusedccp);
            }
            var cloudObj      = Instantiate(cloudPrehab);
            var cloudInstance = cloudObj.GetComponent <Cloud>();

            while (currentClouds.Count() >= 3)
            {
                Destroy(currentClouds[0].gameObject); currentClouds.RemoveAt(0);
            }
            currentClouds.Add(cloudInstance);
            cloudObj.transform.SetParent(cloudPlace.transform, false);
            cloudObj.transform.position = GetInstatntPos(cloudObj) + rb.velocity.SetY(0f) * 0.2f;
            cloudInstance.OnDestroyObsevable
            .FirstOrDefault()
            .Subscribe(_ =>
            {
                currentClouds.Remove(cloudInstance);
                Destroy(cloudObj);
            });
        }
Exemplo n.º 2
0
        private void CreateAttackCloud(GameObject cloud)
        {
            var cloudObj    = Instantiate(cloud);
            var attackCloud = cloudObj.GetComponent <AttackCloud>();

            if (attackCloud.UsedCp > playerCP.CurrentCloudPoint.Value)
            {
                Destroy(cloudObj); return;
            }
            else
            {
                playerCP.ChangeCP(-attackCloud.UsedCp);
            }
            onUseAttackCloudSubject.OnNext(attackCloud.GetAttackCloudEnum);
            StartCoroutine(ChangeWeather(5f));
            cloudObj.transform.SetParent(cloudPlace, false);
            cloudObj.transform.position = this.transform.position + new Vector3(0f, 4f, 0f);
            attackCloud.Init(core, transform.forward);
            attackCloud.OnDestroyObservable
            .Subscribe(_ => Destroy(cloudObj));
        }