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
 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.º 3
0
    void Count()
    {
        count++;
        if (count == 10)
        {
            TrackingManager.TrackingCall_EasterEgg("10", PlayerLevel.Instance.GetCurrentLevel());
            WaypointMover          mover = gameObject.AddComponent <WaypointMover>();
            UnitRotationController contr = gameObject.AddComponent <UnitRotationController>().Init(mover, _foo);
            contr.TurnToPosition(Camera.main.transform, () => m_animation.SetTrigger(UnitAnimationTypes.bAggro.ToString()));
        }
        else if (count == 20)
        {
            TrackingManager.TrackingCall_EasterEgg("20", PlayerLevel.Instance.GetCurrentLevel());
            m_animation.SetTrigger(UnitAnimationTypes.bDying.ToString());
        }
        else if (count == 3 || (count > 3 && M_Math.Roll(0.1f)))
        {
            TrackingManager.TrackingCall_EasterEgg("3", PlayerLevel.Instance.GetCurrentLevel());

            m_animation.SetTrigger(UnitAnimationTypes.bHit.ToString());
        }
    }
Exemplo n.º 4
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);
    }