Esempio n. 1
0
    /////////////////////////////////////////////////////////////////////////////
    /// Function:               Update
    /////////////////////////////////////////////////////////////////////////////
    void Update()
    {
        string strFunction = "CSpawner::Update()";

        if (null == m_ItemsResource)
        {
            m_ItemsResource = Resources.Load <CPowerUpSO>(ResourcePacks.RESOURCE_CONTAINER_ITEMS);
            if (null == m_ItemsResource)
            {
                Debug.LogError(string.Format("{0} {1}: {2}", strFunction, ErrorStrings.ERROR_CANNOT_LOAD_RESOURCE, ResourcePacks.RESOURCE_CONTAINER_ITEMS));
                return;
            }
        }

        if (null == m_NPCResource)
        {
            m_NPCResource = Resources.Load <CNPCSO>(ResourcePacks.RESOURCE_CONTAINER_NPCS);
            if (null == m_ItemsResource)
            {
                Debug.LogError(string.Format("{0} {1}: {2}", strFunction, ErrorStrings.ERROR_CANNOT_LOAD_RESOURCE, ResourcePacks.RESOURCE_CONTAINER_NPCS));
                return;
            }
        }

        if (null == m_goFlagPrefab)
        {
            m_goFlagPrefab = m_NPCResource.Flag;
            if (null == m_goFlagPrefab)
            {
                Debug.LogError(string.Format("{0} {1}: {2}", strFunction, ErrorStrings.ERROR_NULL_OBJECT, typeof(GameObject).ToString()));
            }
        }
    }
        // Use this for initialization
        void Awake()
        {
            if (Network.isServer)
            {
                m_liControllers.Add(this);
                serverManager = RoleManager.roleManager as ServerManager;
            }

            animator       = GetComponent <Animator>();
            animatorStates = new Dictionary <int, AnimatorBoolProperty>();
            animatorStates.Add(0, new AnimatorBoolProperty()
            {
                Name = "bIsMoving", State = false
            });                                                                                      // Moving
            animatorStates.Add(1, new AnimatorBoolProperty()
            {
                Name = "bIsTurningL", State = false
            });                                                                                        // TurnL
            animatorStates.Add(2, new AnimatorBoolProperty()
            {
                Name = "bIsTurningR", State = false
            });                                                                                        // TurnR

            itemsResource     = Resources.Load <CPowerUpSO>(ResourcePacks.RESOURCE_CONTAINER_ITEMS);
            projectilePrefabs = itemsResource.Weapons;
            //inventory.Add(Names.NAME_BULLET, 500);
        }
Esempio n. 3
0
    /////////////////////////////////////////////////////////////////////////////
    /// Function:               Start
    /////////////////////////////////////////////////////////////////////////////
    protected void Start()
    {
        // Error reporting.
        string strFunction = "IAIBase::Start()";

        // Load the items resource.
        if (null == m_ItemsResource)
        {
            m_ItemsResource = Resources.Load <CPowerUpSO>(ResourcePacks.RESOURCE_CONTAINER_ITEMS);
            if (null == m_ItemsResource)
            {
                Debug.LogError(string.Format("{0} {1} " + ErrorStrings.ERROR_AUDIO_FAILED_RELOAD, strFunction, ResourcePacks.RESOURCE_CONTAINER_ITEMS));
                return;
            }
        }

        // Load in the projectile prefabs.
        m_dictProjectilePrefabs = m_ItemsResource.Weapons;

        // Add this NPC to the correct list depending on its team.
        switch (m_eTeam)
        {
        case ETeam.TEAM_BLUE:

            m_liActiveBlues.Add(gameObject);

            break;

        case ETeam.TEAM_RED:

            m_liActiveReds.Add(gameObject);

            break;

        default:

            // Unassigned NPC detected, report the issue.
            Debug.LogError(string.Format("{0} {1}: {2}", strFunction, ErrorStrings.ERROR_UNASSIGNED_NPC, transform.position));

            return;
        }

        // Initialize inventory stock.
        m_dictInventory.Add(Names.NAME_BULLET, 500);
        m_dictInventory.Add(Names.NAME_MISSILE, 0);
        m_dictInventory.Add(Names.NAME_RAY, 0);

        // Get a handle on the NPC's animator.
        m_anAnimator = gameObject.GetComponent <Animator>();
        if (null == m_anAnimator)
        {
            // Shit happened
            Debug.LogError(string.Format("{0} {1}: {2}", strFunction, ErrorStrings.ERROR_MISSING_COMPONENT, typeof(Animator).ToString()));
            return;
        }

        m_dictAnimatorStates = new Dictionary <int, AnimatorBoolProperty>();
        m_dictAnimatorStates.Add(0, new AnimatorBoolProperty()
        {
            Name = AnimatorValues.ANIMATOR_IS_MOVING, State = false
        });                                                                                                                   // Moving
        m_trObservedTransform = transform;
    }