Esempio n. 1
0
    void Update()
    {
        if (m_entity.m_ai_type == AITYPE.INANIMATE)
        {
            return;
        }
        GMobile    mob = m_entity.m_mobile;
        GCombatant com = m_entity.m_combatant;

        //Vector3 dir = Quaternion.AngleAxis(-Camera.main.transform.rotation.eulerAngles.y,Vector3.up) * mob.GetMovementDirection();
        Vector3 dir = Util.RotateDirectionToMatchCamera(mob.GetMovementDirection());

        if (
            m_renderer.flipX != m_turned &&
            m_animator.GetCurrentAnimatorStateInfo(0).normalizedTime > 1 &&
            !m_animator.IsInTransition(0)
            )
        {
            m_renderer.flipX = m_turned;
            if (m_shadow_animator != null)
            {
                m_shadow_renderer.flipX = m_turned;
            }
        }
        if (mob.IsStationary() && !IsPlaying("Turn"))
        {
            PlayNormal("Stand");
        }
        else if (dir.x > 0)
        {
            if (m_turned == false)
            {
                PlayNormal("Turn");
                m_turned = true;
            }
            else if (!IsPlaying("Turn"))
            {
                PlayNormal("Walk");
            }
        }
        else if (dir.x < 0)
        {
            if (m_turned == true)
            {
                PlayNormal("Turn");
                m_turned = false;
            }
            else if (!IsPlaying("Turn"))
            {
                PlayNormal("Walk");
            }
        }
    }
Esempio n. 2
0
    protected virtual void Start()
    {
        m_controller = Game.controller;
        if (m_is_team_leader)
        {
            m_controller.GetTeam(m_team_id).SetLeader(this);
        }

        m_mobile    = gameObject.AddComponent <GMobile>();
        m_combatant = gameObject.AddComponent <GCombatant>();
        m_actor     = gameObject.AddComponent <GActor>();

        m_health = new GameResource(m_max_health, 0, m_max_health);
        m_energy = new GameResource(100, 0, 100);

        m_player_control = gameObject.AddComponent <GPlayer>();
        m_ai_control     = gameObject.AddComponent <GEntityAI>();

        m_appearance_root = transform.Find("Appearance").gameObject;
        m_mobile.SetFlip(m_appearance_root, true, false);

        m_combatant.FillDummyActions();

        m_combatant.SetAction(
            "Attack", "A deadly attack.",
            new GActionTimer(ACTION.ATTACK, 0.5f, 0.25f, 0.25f, 1f, m_combatant.GenericActionStart, null),
            m_basic_attack_prefab,
            null,
            new ACTION_EFFECT[1] {
            ACTION_EFFECT.TELEPORT
        },
            Resources.Load <Sprite>("Icons/ui_2x_laser_icon"),
            m_attack_range, m_attack_damage, true, true, true, true
            );
        m_combatant.SetAction(
            "Block", "An impenetrable block.",
            new GActionTimer(ACTION.BLOCK, 0.1f, 0.1f, 0f, 1f, m_combatant.BlockActionStart, m_combatant.BlockActionEnd),
            m_basic_attack_prefab,
            null,
            new ACTION_EFFECT[0],
            Resources.Load <Sprite>("Icons/ui_2x_laser_icon"),
            10, 10, true, true, true, true
            );
        m_combatant.SetAction(
            "Single Shot", "Pew.",
            new GActionTimer(ACTION.SINGLE_SHOT, 0.1f, 0.1f, 0.2f, 1f, m_combatant.GenericActionStart, null),
            Resources.Load <GameObject>("Weapons/OLD/PlayerLaserSmall"),
            null,
            new ACTION_EFFECT[0],
            Resources.Load <Sprite>("Icons/ui_single_laser_icon"),
            10, 10, true, true, true, true
            );
        m_combatant.SetAction(
            "Double Shot", "Pew pew.",
            new GActionTimer(ACTION.DOUBLE_SHOT, 0f, 0f, 0.25f, 1f, m_combatant.GenericActionStart, null),
            Resources.Load <GameObject>("Weapons/PlayerDoubleLaser"),
            null,
            new ACTION_EFFECT[0],
            Resources.Load <Sprite>("Icons/ui_2x_laser_icon"),
            10, 10, true, true, true, true
            );
    }