Exemplo n.º 1
0
 protected Plant(IMap map, IGrowable growable, IEatable eatable, DeathEvent deathEvent, IEventRecorder eventRecorder)
     : base(map, growable, deathEvent, eventRecorder)
 {
     Status   = Status.Child;
     _eatable = eatable;
     _eatable.EatableOwner = this;
 }
Exemplo n.º 2
0
 public Fish(IMap map, IGrowable growable, IMovable movable, IEater eater, IEatable eatable, IGender gender,
             DeathEvent deathEvent, IEventRecorder eventRecorder)
     : base(map, growable, movable, eater, gender, deathEvent, eventRecorder)
 {
     Hp       = 10;
     _eatable = eatable;
     _eatable.EatableOwner = this;
 }
Exemplo n.º 3
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        IGrowable growable = collision.GetComponent <IGrowable>();

        if (growable != null)
        {
            growable.Grow(m_GrowAmount);
            gameObject.SetActive(false);
        }
    }
Exemplo n.º 4
0
 protected Animal(IMap map, IGrowable growable, IMovable movable, IEater eater, IGender gender,
                  DeathEvent deathEvent, IEventRecorder eventRecorder) : base(map, growable, deathEvent, eventRecorder)
 {
     IsPregnant          = false;
     _gender             = gender;
     _gender.GenderOwner = this;
     _eater                = eater;
     _eater.EaterOwner     = this;
     _movable              = movable;
     _movable.MovableOwner = this;
 }
Exemplo n.º 5
0
 public Sparrow(IMap map, IGrowable growable, IMovable movable, IEater eater, IGender gender,
                DeathEvent deathEvent, IEventRecorder eventRecorder)
     : base(map, growable, movable, eater, gender, deathEvent, eventRecorder)
 {
     Hp = 10;
 }
Exemplo n.º 6
0
 protected Creature(IMap map, IGrowable growable, DeathEvent deathEvent, IEventRecorder eventRecorder) : base(map, deathEvent, eventRecorder)
 {
     CurrentAge = 0;
     _growable  = growable;
     _growable.GrowableOwner = this;
 }
Exemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (_StartingTime <= 0)
        {
            if (!_SpawnedEnding && _Properties.GetEndingParticle() != null)
            {
                GameObject temp = Instantiate(_Properties.GetEndingParticle(), gameObject.transform);
                Destroy(temp, _EndingTime);
                _SpawnedEnding = true;
            }

            if (_PlayedCastingAudio)
            {
                if (_Properties.IsCastingLoop())
                {
                    AudioManager.Instance.StopSE(_Properties.GetCastingAudio().name);
                    _PlayedCastingAudio = false;
                }
            }

            if (!_PlayedEndingAudio)
            {
                if (_Properties.GetEndingAudio() != null)
                {
                    _PlayedEndingAudio = true;
                    AudioManager.Instance.PlaySE(_Properties.GetEndingAudio().name, _Properties.IsEndingLoop());
                }
            }

            if (_EndingTime <= 0)
            {
                gameObject.SetActive(false);

                if (_PlayedEndingAudio)
                {
                    if (_Properties.IsEndingLoop())
                    {
                        AudioManager.Instance.StopSE(_Properties.GetEndingAudio().name);
                        _PlayedEndingAudio = false;
                    }
                }
            }
            else
            {
                _EndingTime -= Time.deltaTime;
            }
        }
        else
        {
            _StartingTime -= Time.deltaTime;
        }

        switch (_Properties.GetEffectType(_StartingTime <= 0))
        {
        case EnumHolder.AreaEffectType.SPAWNING:
        {
            if (_Delay <= 0)
            {
                int temp_target = Random.Range(0, _Properties.GetTargetable().GetList().Count);

                GameObject temp_obj = ObjectManager.Instance.InstantiateWithObjectPooling(
                    _Properties.GetTargetable().GetList()[temp_target],
                    new Vector3(
                        gameObject.transform.position.x + Random.Range(-_Properties.GetRadius(), _Properties.GetRadius()),
                        gameObject.transform.position.y + _Properties.GetYOffset(),
                        gameObject.transform.position.z + Random.Range(-_Properties.GetRadius(), _Properties.GetRadius())
                        ));

                if (temp_obj.tag.Equals("Slime"))
                {
                    Stats     temp           = EnumHolder.Instance.GetStats(_Properties.GetTargetable().GetList()[temp_target].name);
                    SlimeBase temp_component = temp_obj.GetComponent <SlimeBase>();

                    if (temp_component != null)
                    {
                        Destroy(temp_component);
                    }

                    int type = Random.Range(0, _Properties.GetElement().GetList().Count);

                    System.Type _MyScriptType = System.Type.GetType(((ElementType)_Properties.GetElement().GetList()[type]).GetSlimeScriptName());
                    SlimeBase   temp_script   = temp_obj.AddComponent(_MyScriptType) as SlimeBase;

                    temp_script.Init(temp, ((((ElementType)_Properties.GetElement().GetList()[type]).name.Equals("Lightning")) ? 2 : 1), ((ElementType)_Properties.GetElement().GetList()[type]), _Properties.GetTier());
                }

                _Delay = _Properties.GetDelay();
            }
            else
            {
                _Delay -= Time.deltaTime;
            }
        }
        break;

        case EnumHolder.AreaEffectType.SUCKING:
        {
            foreach (GameObject obj in _Properties.GetTargetable().GetList())
            {
                if (ObjectManager.Instance.GetActiveObjects(obj) != null)
                {
                    foreach (GameObject entity in ObjectManager.Instance.GetActiveObjects(obj))
                    {
                        if (Vector3.Distance(gameObject.transform.position, entity.transform.position) < _Properties.GetRadius())
                        {
                            entity.transform.position = Vector3.Slerp(entity.transform.position, new Vector3(gameObject.transform.position.x, entity.transform.position.y, gameObject.transform.position.z), (1.0f - (Vector3.Distance(gameObject.transform.position, entity.transform.position) / _Properties.GetRadius())) * 0.5f);
                        }
                    }
                }
            }
        }
        break;

        case EnumHolder.AreaEffectType.PUSHING:
        {
            foreach (GameObject obj in _Properties.GetTargetable().GetList())
            {
                if (ObjectManager.Instance.GetActiveObjects(obj) != null)
                {
                    foreach (GameObject entity in ObjectManager.Instance.GetActiveObjects(obj))
                    {
                        if (Vector3.Distance(gameObject.transform.position, entity.transform.position) < _Properties.GetRadius())
                        {
                            entity.transform.position += (
                                new Vector3(entity.transform.position.x, entity.transform.position.y, entity.transform.position.z) -
                                new Vector3(gameObject.transform.position.x, entity.transform.position.y, gameObject.transform.position.z)).normalized *
                                                         (1.0f - (Vector3.Distance(gameObject.transform.position, entity.transform.position) / _Properties.GetRadius()));

                            if (_Delay <= 0)
                            {
                                IDamageable dmg = entity.GetComponent <IDamageable>();
                                if (dmg != null)
                                {
                                    if (Vector3.Distance(gameObject.transform.position, entity.transform.position) < _Properties.GetRadius())
                                    {
                                        dmg.TakeDamage(_Properties.GetDamage());
                                    }
                                }
                                _Delay = _Properties.GetDelay();
                            }
                            else
                            {
                                _Delay -= Time.deltaTime;
                            }
                        }
                    }
                }
            }
        }
        break;

        case EnumHolder.AreaEffectType.DAMAGE:
        {
            if (_Delay <= 0)
            {
                foreach (GameObject obj in _Properties.GetTargetable().GetList())
                {
                    if (ObjectManager.Instance.GetActiveObjects(obj) != null)
                    {
                        foreach (GameObject entity in ObjectManager.Instance.GetActiveObjects(obj))
                        {
                            IDamageable dmg = entity.GetComponent <IDamageable>();
                            if (dmg != null)
                            {
                                if (Vector3.Distance(gameObject.transform.position, entity.transform.position) < _Properties.GetRadius())
                                {
                                    dmg.TakeDamage(_Properties.GetDamage());
                                    if (LayerMask.LayerToName(entity.layer) == "Slime")
                                    {
                                        entity.SetActive(false);
                                    }
                                }
                            }
                        }
                    }
                }

                _Delay = _Properties.GetDelay();
            }
            else
            {
                _Delay -= Time.deltaTime;
            }
        }
        break;

        case EnumHolder.AreaEffectType.GROWING:
        {
            if (_Delay <= 0)
            {
                foreach (GameObject obj in _Properties.GetTargetable().GetList())
                {
                    if (ObjectManager.Instance.GetActiveObjects(obj) != null)
                    {
                        foreach (GameObject entity in ObjectManager.Instance.GetActiveObjects(obj))
                        {
                            IGrowable grow = entity.GetComponent <IGrowable>();
                            if (grow != null)
                            {
                                if (Vector3.Distance(gameObject.transform.position, entity.transform.position) < _Properties.GetRadius())
                                {
                                    grow.Grow(_Properties.GetTier());
                                }
                            }
                        }
                    }
                }

                _Delay = _Properties.GetDelay();
            }
            else
            {
                _Delay -= Time.deltaTime;
            }
        }
        break;

        default:
            break;
        }
    }
Exemplo n.º 8
0
 public Tree(IMap map, IGrowable growable, IEatable eatable, DeathEvent deathEvent, IEventRecorder eventRecorder)
     : base(map, growable, eatable, deathEvent, eventRecorder)
 {
     Hp = 500;
 }
Exemplo n.º 9
0
        private void ApplyGrowPlus(Creature consumer, IGrowable growable, UseItemCallback postItemUseCallback)
        {
            consumer.IncreaseLust(10);

            postItemUseCallback(true, growable.UseGroPlus(), null, null);
        }