public void Awake() {
		_cachedTransform = transform;
		
		if (_model == null) {
			_model = gameObject.GetComponentInChildren<UnitModelView>();
		}
		
		EventsAggregator.Units.AddListener<BaseUnit, HitInfo>(EUnitEvent.HitReceived, OnHitReceived);
		EventsAggregator.Units.AddListener<BaseUnit>(EUnitEvent.DeathCame, OnUnitDeath);
		EventsAggregator.Fight.AddListener(EFightEvent.Pause, OnFightPause);
		EventsAggregator.Fight.AddListener(EFightEvent.Resume, OnFightResume);
		EventsAggregator.Fight.AddListener(EFightEvent.MapComplete, OnMapComplete);
		EventsAggregator.Fight.AddListener(EFightEvent.MapFail, OnMapFail);
	}
Ejemplo n.º 2
0
    public void Awake()
    {
		if (_model == null) 
			_model = gameObject.GetComponentInChildren<UnitModelView>();
        _model.MovementSpeed = _speed;
        _modelTransform = _model.transform;
        _transform = transform;

        _attackActions.Add(EUnitAttackState.NoAttack, MoveToPosition); 
        _attackActions.Add(EUnitAttackState.WatchTarget, WatchTarget);
        _attackActions.Add(EUnitAttackState.AttackTarget, AttackTarget);

        _attackActions.Add(EUnitAttackState.LookIntoSunset, LookForward);
        _attackActions.Add(EUnitAttackState.WalkIntoSunset, MoveForward);
    }
Ejemplo n.º 3
0
    public void Awake()
    {
        _cachedTransform = transform;

        if (_model == null)
        {
            _model = gameObject.GetComponentInChildren <UnitModelView>();
        }

        EventsAggregator.Units.AddListener <BaseUnit, HitInfo>(EUnitEvent.HitReceived, OnHitReceived);
        EventsAggregator.Units.AddListener <BaseUnit>(EUnitEvent.DeathCame, OnUnitDeath);
        EventsAggregator.Fight.AddListener(EFightEvent.Pause, OnFightPause);
        EventsAggregator.Fight.AddListener(EFightEvent.Resume, OnFightResume);
        EventsAggregator.Fight.AddListener(EFightEvent.MapComplete, OnMapComplete);
        EventsAggregator.Fight.AddListener(EFightEvent.MapFail, OnMapFail);
    }
Ejemplo n.º 4
0
    public void Awake()
    {
        if (_model == null)
        {
            _model = gameObject.GetComponentInChildren <UnitModelView>();
        }
        _model.MovementSpeed = _speed;
        _modelTransform      = _model.transform;
        _transform           = transform;

        _attackActions.Add(EUnitAttackState.NoAttack, MoveToPosition);
        _attackActions.Add(EUnitAttackState.WatchTarget, WatchTarget);
        _attackActions.Add(EUnitAttackState.AttackTarget, AttackTarget);

        _attackActions.Add(EUnitAttackState.LookIntoSunset, LookForward);
        _attackActions.Add(EUnitAttackState.WalkIntoSunset, MoveForward);
    }
Ejemplo n.º 5
0
    public void OnDestroy()
    {
        EventsAggregator.Units.RemoveListener <BaseUnit, HitInfo>(EUnitEvent.HitReceived, OnHitReceived);
        EventsAggregator.Units.RemoveListener <BaseUnit>(EUnitEvent.DeathCame, OnUnitDeath);
        EventsAggregator.Fight.RemoveListener(EFightEvent.Pause, OnFightPause);
        EventsAggregator.Fight.RemoveListener(EFightEvent.Resume, OnFightResume);
        EventsAggregator.Fight.RemoveListener(EFightEvent.MapComplete, OnMapComplete);
        EventsAggregator.Fight.RemoveListener(EFightEvent.MapFail, OnMapFail);

        if (_isAlly && UnitsConfig.Instance != null && UnitsConfig.Instance.IsHero(_unitData.Data.Key))
        {
            EventsAggregator.Units.RemoveListener <ESkillKey>(EUnitEvent.SkillUsage, UseSkill);
        }

        _unitData       = null;
        _lastTargetUnit = _targetUnit = null;
        _unitAttack     = null;
        //_unitPathfinder = null;
        _model = null;
        _ui    = null;
    }
Ejemplo n.º 6
0
    public void OnDestroy()
    {
        EventsAggregator.Units.RemoveListener<BaseUnit, HitInfo>(EUnitEvent.HitReceived, OnHitReceived);
        EventsAggregator.Units.RemoveListener<BaseUnit>(EUnitEvent.DeathCame, OnUnitDeath);
        EventsAggregator.Fight.RemoveListener(EFightEvent.Pause, OnFightPause);
        EventsAggregator.Fight.RemoveListener(EFightEvent.Resume, OnFightResume);
        EventsAggregator.Fight.RemoveListener(EFightEvent.MapComplete, OnMapComplete);
        EventsAggregator.Fight.RemoveListener(EFightEvent.MapFail, OnMapFail);

        if (_isAlly && UnitsConfig.Instance != null && UnitsConfig.Instance.IsHero(_unitData.Data.Key)) {
            EventsAggregator.Units.RemoveListener<ESkillKey>(EUnitEvent.SkillUsage, UseSkill);
        }

        _unitData = null;
        _lastTargetUnit = _targetUnit = null;
        _unitAttack = null;
        //_unitPathfinder = null;
        _model = null;
        _ui = null;
    }
Ejemplo n.º 7
0
    private void LoadItemsResources(Dictionary <EItemKey, GameObject[]> resourcesDic, EUnitKey unitKey, UnitModelView unitModelView, EItemKey weaponRKey, EItemKey weaponLKey, EItemKey armorKey)
    {
        if (unitModelView != null)
        {
            GameObject rhWeaponResource  = null;
            GameObject lhWeaponResource  = null;
            GameObject headArmorResource = null;
            GameObject bodyArmorResource = null;

            unitModelView.SetWeaponType(weaponRKey, weaponLKey);

            //right hand weapon
            if (!resourcesDic.ContainsKey(weaponRKey))
            {
                GameObject[] weaponResources = new GameObject[1];
                weaponResources[0] = Resources.Load(string.Format("{0}/{1}", GameConstants.Paths.ITEM_RESOURCES, GetItemResourcePath(weaponRKey))) as GameObject;
                resourcesDic.Add(weaponRKey, weaponResources);

                rhWeaponResource = weaponResources[0];
            }
            else if (weaponRKey != EItemKey.None)
            {
                rhWeaponResource = resourcesDic[weaponRKey][0];
            }

            //left hand weapon
            if (!resourcesDic.ContainsKey(weaponLKey))
            {
                GameObject[] weaponResources = new GameObject[1];
                weaponResources[0] = Resources.Load(string.Format("{0}/{1}", GameConstants.Paths.ITEM_RESOURCES, GetItemResourcePath(weaponLKey))) as GameObject;
                resourcesDic.Add(weaponLKey, weaponResources);

                lhWeaponResource = weaponResources[0];
            }
            else if (weaponLKey != EItemKey.None)
            {
                lhWeaponResource = resourcesDic[weaponLKey][0];
            }

            //armor
            if (armorKey == EItemKey.None)
            {
                //Debug.LogWarning(string.Format("No armor set for {0} unit", unitKey));
            }
            else if (!resourcesDic.ContainsKey(armorKey))
            {
                string armorResourcePath = GetItemResourcePath(armorKey);

                GameObject[] armorResources = new GameObject[2];
                armorResources[0] = Resources.Load(string.Format("{0}/{1}_head", GameConstants.Paths.ITEM_RESOURCES, armorResourcePath)) as GameObject;
                armorResources[1] = Resources.Load(string.Format("{0}/{1}_body", GameConstants.Paths.ITEM_RESOURCES, armorResourcePath)) as GameObject;
                resourcesDic.Add(armorKey, armorResources);

                headArmorResource = armorResources[0];
                bodyArmorResource = armorResources[1];
            }
            else
            {
                headArmorResource = resourcesDic[armorKey][0];
                bodyArmorResource = resourcesDic[armorKey][1];
            }

            unitModelView.SetupGraphics(rhWeaponResource, lhWeaponResource, headArmorResource, bodyArmorResource);
        }
    }