Exemplo n.º 1
0
    IEnumerator Sequence(UnitAnimationTypes anim, AudioClip exec_audio, Unit caster, Transform target, EventHandler callback_execute)
    {
        UnitAnimationController anim_controller     = m_Unit.GetComponentInChildren <UnitAnimationController>();
        UnitRotationController  rotation_controller = m_Unit.GetComponentInChildren <UnitRotationController>();

        TurnEventQueue.CameraFocusEvent cam_pan = new TurnEventQueue.CameraFocusEvent(caster.transform.position);

        yield return(StartCoroutine(cam_pan.WaitForEvent()));


        if (rotation_controller != null)
        {
            yield return(StartCoroutine(rotation_controller.TurnToTargetPositiom(target, null)));
        }

        if (anim_controller != null)
        {
            anim_controller.PlayAnimation(anim, callback_execute);
        }

        if (exec_audio != null)
        {
            SoundManager.PlaySFX(exec_audio, caster.transform);
        }
        OnExected(caster, target);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    private void Initialize()
    {
        print("Unit.Initialize");
        Transform unitSpriteTransform = transform.Find("Sprite(Clone)");

        _unitAnimationController         = unitSpriteTransform.GetComponent <UnitAnimationController> ();
        _spriteRenderer                  = unitSpriteTransform.GetComponent <SpriteRenderer> ();
        _attributeCollection             = UnitData.AttributeCollection;
        _effectCollection                = new EffectCollection();
        _modifyAttributeEffectCollection = new ModifyAttributeEffectCollection();
        _unitColorEffects                = new List <UnitColorEffect> ();
        SetMaximumValueToCurrentValue(AttributeEnums.AttributeType.HIT_POINTS);
        SetMaximumValueToCurrentValue(AttributeEnums.AttributeType.ABILITY_POINTS);
        _inventorySlots = UnitData.InventorySlots;
        _canvas         = transform.Find("Canvas").GetComponent <Canvas> ();
        FacedDirection  = TileDirection.EAST;

        _characterSheetController = GameManager.Instance.GetCharacterSheetController();
        _combatMenuController     = GameManager.Instance.GetCombatMenuController();

        TileHighlighter = new TileHighlighter(GameManager.Instance.GetTileMap(), _movementHighlightCube);

        _movementAudioSource = gameObject.AddComponent <AudioSource> ();
        _weaponAudioSource   = gameObject.AddComponent <AudioSource> ();

        _currentColor = DefaultColor;
    }
    /// <summary>
    /// Applies the effect.
    /// </summary>
    /// <param name="unit">Unit.</param>
    public override void ApplyEffect(Unit unit)
    {
        UnitAnimationController animationController = unit.GetAnimationController();

        _oldSpeed = animationController.GetSpeed();
        animationController.SetSpeed(_newSpeed);
        base.ApplyEffect(unit);
    }
Exemplo n.º 4
0
 public override void SetupController(TraitController controller)
 {
     base.SetupController(controller);
     _animationController = Instantiate(FactoryController.UNIT_ANIMATION_CONTROLLER, _controller.transform.parent);
     _animationController.Animator.runtimeAnimatorController = _runtimeController;
     _animationController.SpriteRenderer.color = _color;
     SubscribeToMessages();
 }
Exemplo n.º 5
0
 protected override void Awake()
 {
     base.Awake();
     nameObject = "enemy";
     motor      = GetComponent <UnitMotor>();
     anim       = GetComponent <UnitAnimationController>();
     canAttack  = false;
 }
Exemplo n.º 6
0
 public AIAggroEvent(UnitAI _ai, Unit _target)
 {
     ai       = _ai;
     target   = _target;
     rotator  = ai.GetComponentInChildren <UnitRotationController>();
     animator = ai.GetComponentInChildren <UnitAnimationController>();
     MDebug.Log("Turnevent Queue start aggro");
     Execute(0);
 }
Exemplo n.º 7
0
    protected override void Awake()
    {
        Debug.Log("PlayerManager");
        //base.Awake();
        instance   = this;
        nameObject = "player";
        //LoadSaveSystem.instance.Defolt();
        health    = LoadSaveSystem.instance.LoadHealth();
        maxHealth = LoadSaveSystem.instance.LoadMaxHealth();
        damage    = LoadSaveSystem.instance.LoadDamage();

        motor = GetComponent <UnitMotor>();
        anim  = GetComponent <UnitAnimationController>();
        //OnChangeHealth += healthSystem.UpdateHealthPointRander;
    }
Exemplo n.º 8
0
        public DeathEvent(Unit u)
        {
            EventID = "UNIT DEATH";
            StartEvent();
            m_unit = u;

            UnitAnimationController animationController = m_unit.GetComponentInChildren <UnitAnimationController>();

            if (animationController != null)
            {
                animationController.PlayAnimation(UnitAnimationTypes.bDying, null);
            }

            Sequence seq = DOTween.Sequence().InsertCallback(4f, () => EndEvent());

            seq.Play();
        }
    /// <summary>
    /// Plays the attack animations.
    /// </summary>
    /// <returns>The attack animations.</returns>
    /// <param name="attacker">Attacker.</param>
    /// <param name="direction">Direction.</param>
    protected IEnumerator PlayAttackAnimations(Unit attacker, Vector3 direction)
    {
        Ability.AbilityType abilityType = attacker.Action.Ability.Type;
        if (abilityType == Ability.AbilityType.ATTACK || attacker.Action.Ability.Id == AbilityConstants.MEASURED_STRIKE)
        {
            //determine which way to swing, dependent on the direction the enemy is
            Unit.TileDirection      facing = attacker.GetDirectionToTarget(direction);
            UnitAnimationController animationController = attacker.GetAnimationController();
            switch (facing)
            {
            case Unit.TileDirection.NORTH:
                animationController.AttackNorth();
                break;

            case Unit.TileDirection.EAST:
                animationController.AttackEast();
                break;

            case Unit.TileDirection.SOUTH:
                animationController.AttackSouth();
                break;

            case Unit.TileDirection.WEST:
                animationController.AttackWest();
                break;
            }
        }
        else if (attacker.Action.Ability.Id == AbilityConstants.WHIRLWIND_SLASH)
        {
            UnitAnimationController animationController = attacker.GetAnimationController();
            animationController.WhirlwindSlash();
        }
        else if (attacker.Action.Ability.Id == AbilityConstants.LEAPING_SLICE)
        {
            UnitAnimationController animationController = attacker.GetAnimationController();
            animationController.LeapingSlice();
        }

        yield return(null);
    }
Exemplo n.º 10
0
    private void DeathCheck()
    {
        if (Health <= 0)
        {
            //Play deatch clip

            despawnTimer += Time.deltaTime;
            UnitAnimationController anim = GetUnitAnimationController();
            if (anim != null)
            {
                anim.Death();
            }
        }

        if (despawnTimer >= DespawnTime)
        {
            Destroy(gameObject);

            if (Commander.Base.CommandHUB != null)
            {
                Commander.Base.CommandHUB.UniCamSwitch.notificationController.UnitDestroyed(Name);
            }
        }
    }
 public void Awake()
 {
     UnitAbilityManager      = GetComponent <UnitAbilityManager>();
     UnitAnimationController = GetComponent <UnitAnimationController>();
 }
Exemplo n.º 12
0
    /// <summary>
    /// Returns the instance of a unit
    /// </summary>
    /// <param name="data">Unit Config to determine unit type, stats, actions</param>
    /// <returns></returns>
    public static Unit CreateUnit(ScriptableUnitConfig data, int group, M_Math.R_Range initiative_range, bool hide_player)
    {
        if (data == null)
        {
            Debug.LogWarning("cant create unit, data == null");
            return(null);
        }
        MDebug.Log("^unitCreating Unit " + data.ID);
        GameObject         base_unit      = Instantiate(Resources.Load("base_unit")) as GameObject;
        SpawnLootOnDeath   loot           = base_unit.AddComponent <SpawnLootOnDeath>();
        Unit_EffectManager effect_manager = base_unit.AddComponent <Unit_EffectManager>();
        UnitStats          stats          = MakeStats(base_unit, data, effect_manager, initiative_range);
        UnitInventory      inventory      = MakeInventory(data, base_unit, stats);
        ActionManager      actions        = MakeActions(data, base_unit);


        UnitAdrenalineRushParticleManager adr_particles = base_unit.GetComponent <UnitAdrenalineRushParticleManager>();

        Unit                    m_unit          = base_unit.AddComponent <Unit>();
        GameObject              mesh            = MakeMesh(data, m_unit);
        Unit_UnitDeath          unit_death      = base_unit.AddComponent <Unit_UnitDeath>();
        Unit_UnitEvacuation     unit_evac       = base_unit.AddComponent <Unit_UnitEvacuation>();
        UnitAnimationController animations      = mesh.AddComponent <UnitAnimationController>();
        Unit_SoundController    sound           = base_unit.AddComponent <Unit_SoundController>();
        UnitRotationController  rotator         = base_unit.AddComponent <UnitRotationController>();
        SpeechManager_Unit      speech_mananger = base_unit.AddComponent <SpeechManager_Unit>();

        m_unit.OwnerID = data.Owner;
        m_unit.Config  = data;

        UI_Unit.CreateUnitUI(m_unit);


        sound.Init(m_unit);
        unit_evac.Init(m_unit);
        adr_particles.Init(stats);
        AddActiveTurnIndicator(m_unit, data.Owner == 0);
        GetName(data, base_unit);
        GiveWeapon(data, mesh, inventory);


        loot.Init(m_unit, data.LootCategory);
        effect_manager.SetUnit(m_unit);
        animations.Init(m_unit, mesh);



        speech_mananger.Init(data.SpeechConfig, m_unit);


        if (data.Owner == 1)
        {
            UnitAI ai = MakeAI(data, group, base_unit, m_unit);
            rotator.Init(m_unit.GetComponent <WaypointMover>(), ai.GetLookRotation);

            ai.OnPreferredTargetChange += unit => new TurnEventQueue.AIAggroEvent(ai, unit);
        }
        else
        {
            rotator.Init(m_unit.GetComponent <WaypointMover>(), delegate     { return(m_unit.transform.position + m_unit.transform.forward); });
        }
        //set mesh inactive
        mesh.gameObject.GetComponentsInChildren <Renderer>().ToList().ForEach(rend => rend.enabled = false);
        //and then identify
        InitIdentified(data, m_unit, hide_player);


        return(m_unit);
    }
 protected internal virtual void SetupStatics()
 {
     UNIT_CONTROLLER           = UnitControllerTemplate;
     TRAIT_CONTROLLER          = TraitControllerTemplate;
     UNIT_ANIMATION_CONTROLLER = UnitAnimationControllerTemplate;
 }