Example #1
0
    void Awake()
    {
        crowdMgr = GetComponent <CrowdManager>();
        crowdMgr.SetNumInstances(Count);

        weaponMgr = GetComponent <WeaponManager>();
        weaponMgr.SetInstanceNum(Count);

        grid        = gameObject.AddComponent <SceneGrid>();
        grid.center = new Vector2(spawnRadius, spawnRadius);

        GridID     = new int[Count];
        Velocities = new Vector3[Count];
        Rotations  = new Quaternion[Count];
        Positions  = new Vector3[Count];
        Weapons    = new int[Count];

        // State machine definitions
        stateDefinition    = new AnimationState[3];
        stateDefinition[0] = new AnimationState(spd => spd < 0.1 ? 0 : 1);
        stateDefinition[1] = new AnimationState(spd => spd < 0.1 ? 0 : (spd >= 9 ? 2 : 1), spd => spd / 9 + 0.3f);
        stateDefinition[2] = new AnimationState(spd => spd < 9 ? 1 : 2);

        // Agent moving toggle
        GameObject AgentMovingToggleComponent = GameObject.Find("AgentMovingToggle");
        Toggle     AgentMovingToggle          = AgentMovingToggleComponent.GetComponent <Toggle>();

        AgentMovingToggle.onValueChanged.AddListener(delegate {
            isAgentMoving = AgentMovingToggle.isOn;
        });
        isAgentMoving = AgentMovingToggle.isOn;
    }