예제 #1
0
    static bool Proc_Travel(CEnemyShip enemyShip)
    {
        switch (enemyShip.m_Event)
        {
        case EEvent.none:                       // Process the state.
            break;

        default:                        // Shutdown the state.
            enemyShip.m_State = EState.none;
            return(true);
        }

        return(false);          // Proc functions return false unless the event is uncaught.
    }
예제 #2
0
    static bool Init_TurnToFaceDisturbance(CEnemyShip enemyShip)
    {
        if (enemyShip.m_State != EState.none)
        {
            Debug.LogError("CEnemyShip: State should be null when initialising a new state!");
        }

        // Initialise the state.
        /*Consume event			*/enemyShip.m_Event = EEvent.none;
        /*Target disturbance?	*/enemyShip.state_TargetDisturbance = true;
        /*Move to target?		*/enemyShip.state_MoveToTarget         = false;
        /*Handle prey target	*/enemyShip.state_Prey = null;
        /*Set state				*/enemyShip.m_State          = EState.turningToFaceDisturbance;

        return(true);           // Init functions always return true.
    }
예제 #3
0
    static bool Proc_ScanForPrey(CEnemyShip enemyShip)
    {
        switch (enemyShip.m_Event)
        {
        case EEvent.none:                       // Process the state.
            // Todo: Scan for prey.
            // If prey is detected, set state_Prey, set event to transition_TurnToFacePrey, and return false.
            break;

        default:                        // Shutdown the state.
            enemyShip.m_State = EState.none;
            return(true);
        }

        return(false);          // Proc functions return false unless the event is uncaught.
    }
예제 #4
0
    static bool Proc_Idle(CEnemyShip enemyShip)
    {
        switch (enemyShip.m_Event)
        {
        case EEvent.none:                       // Process the state.
            if (enemyShip.FindPrey())           // Todo: Do this only periodically.
            {
                enemyShip.m_Event = EEvent.transition_TurnToFacePrey;
            }
            break;

        default:                        // Shutdown the state.
            enemyShip.m_State = EState.none;
            return(true);
        }

        return(false);          // Proc functions return false unless the event is uncaught.
    }
예제 #5
0
    static bool Proc_MoveToDisturbance(CEnemyShip enemyShip)
    {
        switch (enemyShip.m_Event)
        {
        case EEvent.none:                       // Process the state.
            if (enemyShip.state_MovedToTarget)
            {
                enemyShip.m_Event = EEvent.transition_ScanForPrey;
            }
            break;

        default:                        // Shutdown the state.
            enemyShip.m_State = EState.none;
            return(true);
        }

        return(false);          // Proc functions return false unless the event is uncaught.
    }
예제 #6
0
    static bool Proc_TurnToFaceDisturbance(CEnemyShip enemyShip)
    {
        switch (enemyShip.m_Event)
        {
        case EEvent.none:                       // Process the state.
            if (enemyShip.state_LookingAtTarget)
            {
                enemyShip.m_Event = enemyShip.FindPrey() ? EEvent.transition_TurnToFacePrey : EEvent.transition_MoveToDisturbance;
            }
            break;

        default:                        // Shutdown the state.
            enemyShip.m_State = EState.none;
            return(true);
        }

        return(false);          // Proc functions return false unless the event is uncaught.
    }
예제 #7
0
    static bool Proc_TurnToFacePrey(CEnemyShip enemyShip)
    {
        switch (enemyShip.m_Event)
        {
        case EEvent.none:                        // Process the state.
            if (enemyShip.state_LookingAtTarget) // Todo: Raycast check if there is a line of sight to the prey.
            {
                enemyShip.m_Event = EEvent.transition_AttackPrey;
            }
            break;

        default:                        // Shutdown the state.
            enemyShip.m_State = EState.none;
            return(true);
        }

        return(false);          // Proc functions return false unless the event is uncaught.
    }
예제 #8
0
    static bool Init_AttackPrey(CEnemyShip enemyShip)
    {
        if (enemyShip.m_State != EState.none)
        {
            Debug.LogError("CEnemyShip: State should be null when initialising a new state!");
        }

        // Initialise the state.
        /*Consume event			*/enemyShip.m_Event = EEvent.none;
        /*Target disturbance?	*/enemyShip.state_TargetDisturbance = false;
        /*Move to target?		*/enemyShip.state_MoveToTarget         = true;
        /*Handle prey target	*/if (enemyShip.state_Prey == null)
        {
            Debug.LogError("CEnemyShip: Can not attack prey when there is no prey set!");
        }
        /*Set state				*/enemyShip.m_State = EState.attackingPrey;

        return(true);           // Init functions always return true.
    }
예제 #9
0
    static bool Proc_AttackPrey(CEnemyShip enemyShip)
    {
        switch (enemyShip.m_Event)
        {
        case EEvent.none:                       // Process the state.
            if (!enemyShip.state_LookingAtTarget)
            {
                enemyShip.m_Event = EEvent.transition_TurnToFacePrey;
            }
            else
            {
                // Todo: Shoot at the player ship.
            }
            break;

        default:                        // Shutdown the state.
            enemyShip.m_State = EState.none;
            return(true);
        }

        return(false);          // Proc functions return false unless the event is uncaught.
    }
예제 #10
0
    static bool Init_Idle(CEnemyShip enemyShip)
    {
        if (enemyShip.m_State != EState.none)
        {
            Debug.LogError("CEnemyShip: State should be null when initialising a new state!");
        }

        // Initialise the state.
        /*Consume event			*/enemyShip.m_Event = EEvent.none;
        /*Target disturbance?	*/enemyShip.state_TargetDisturbance = false;
        /*Move to target?		*/enemyShip.state_MoveToTarget         = false;
        /*Handle prey target	*/enemyShip.state_Prey = null;
        /*Set state				*/if (Random.Range(0, 2) == 0)
        {
            enemyShip.m_State = EState.idling;
        }
        else
        {
            enemyShip.m_Event = EEvent.transition_Travel; // 50/50 chance to idle or travel.
        }
        return(true);                                     // Init functions always return true.
    }
예제 #11
0
    override public void init()
    {
        base.init();

        mBackground = new CBackground();
        mBackground.setXY(0, 0);

        mPlayer = new CAndy();
        mPlayer.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2);
        mPlayer.setRotation(45);

        CGame.inst().setPlayer(mPlayer);

        mEnemyManager   = new CEnemyManager();
        mBulletManager  = new CBulletManager();
        mParticleManger = new CParticleManager();

        createAsteroids();

        CEnemyShip e = new CEnemyShip();

        e.setXY(200, 200);
        CEnemyManager.inst().add(e);
    }
예제 #12
0
파일: CEnemyShip.cs 프로젝트: nulhax/VOID
	static bool Init_Idle(CEnemyShip enemyShip)
	{
		if (enemyShip.m_State != EState.none) Debug.LogError("CEnemyShip: State should be null when initialising a new state!");

		// Initialise the state.
		/*Consume event			*/enemyShip.m_Event = EEvent.none;
		/*Target disturbance?	*/enemyShip.state_TargetDisturbance = false;
		/*Move to target?		*/enemyShip.state_MoveToTarget = false;
		/*Handle prey target	*/enemyShip.state_Prey = null;
		/*Set state				*/if (Random.Range(0, 2) == 0) enemyShip.m_State = EState.idling; else enemyShip.m_Event = EEvent.transition_Travel;	// 50/50 chance to idle or travel.

		return true;	// Init functions always return true.
	}
예제 #13
0
파일: CEnemyShip.cs 프로젝트: nulhax/VOID
	static bool Proc_AttackPrey(CEnemyShip enemyShip)
	{
		switch (enemyShip.m_Event)
		{
			case EEvent.none:	// Process the state.
				if (!enemyShip.state_LookingAtTarget)
					enemyShip.m_Event = EEvent.transition_TurnToFacePrey;
				else
				{
					// Todo: Shoot at the player ship.
				}
				break;

			default:	// Shutdown the state.
				enemyShip.m_State = EState.none;
				return true;
		}

		return false;	// Proc functions return false unless the event is uncaught.
	}
예제 #14
0
파일: CEnemyShip.cs 프로젝트: nulhax/VOID
	static bool Init_TurnToFacePrey(CEnemyShip enemyShip)
	{
		if (enemyShip.m_State != EState.none) Debug.LogError("CEnemyShip: State should be null when initialising a new state!");

		// Initialise the state.
		/*Consume event			*/enemyShip.m_Event = EEvent.none;
		/*Target disturbance?	*/enemyShip.state_TargetDisturbance = false;
		/*Move to target?		*/enemyShip.state_MoveToTarget = false;
		/*Handle prey target	*/if (enemyShip.state_Prey == null) Debug.LogError("CEnemyShip: Can not face prey when there is no prey set!");
		/*Set state				*/enemyShip.m_State = EState.turningToFacePrey;

		return true;	// Init functions always return true.
	}
예제 #15
0
파일: CEnemyShip.cs 프로젝트: nulhax/VOID
	static bool Proc_MoveToDisturbance(CEnemyShip enemyShip)
	{
		switch (enemyShip.m_Event)
		{
			case EEvent.none:	// Process the state.
				if (enemyShip.state_MovedToTarget)
					enemyShip.m_Event = EEvent.transition_ScanForPrey;
				break;

			default:	// Shutdown the state.
				enemyShip.m_State = EState.none;
				return true;
		}

		return false;	// Proc functions return false unless the event is uncaught.
	}
예제 #16
0
파일: CEnemyShip.cs 프로젝트: nulhax/VOID
	static bool Proc_Idle(CEnemyShip enemyShip)
	{
		switch (enemyShip.m_Event)
		{
			case EEvent.none:	// Process the state.
				if (enemyShip.FindPrey())// Todo: Do this only periodically.
					enemyShip.m_Event = EEvent.transition_TurnToFacePrey;
				break;

			default:	// Shutdown the state.
				enemyShip.m_State = EState.none;
				return true;
		}

		return false;	// Proc functions return false unless the event is uncaught.
	}
예제 #17
0
파일: CEnemyShip.cs 프로젝트: nulhax/VOID
	static bool Proc_ScanForPrey(CEnemyShip enemyShip)
	{
		switch (enemyShip.m_Event)
		{
			case EEvent.none:	// Process the state.
				// Todo: Scan for prey.
				// If prey is detected, set state_Prey, set event to transition_TurnToFacePrey, and return false.
				break;

			default:	// Shutdown the state.
				enemyShip.m_State = EState.none;
				return true;
		}

		return false;	// Proc functions return false unless the event is uncaught.
	}
예제 #18
0
파일: CEnemyShip.cs 프로젝트: nulhax/VOID
	static bool Proc_Travel(CEnemyShip enemyShip)
	{
		switch (enemyShip.m_Event)
		{
			case EEvent.none:	// Process the state.
				break;

			default:	// Shutdown the state.
				enemyShip.m_State = EState.none;
				return true;
		}

		return false;	// Proc functions return false unless the event is uncaught.
	}
예제 #19
0
파일: CEnemyShip.cs 프로젝트: nulhax/VOID
	static bool Proc_TurnToFaceDisturbance(CEnemyShip enemyShip)
	{
		switch (enemyShip.m_Event)
		{
			case EEvent.none:	// Process the state.
				if (enemyShip.state_LookingAtTarget)
					enemyShip.m_Event = enemyShip.FindPrey() ? EEvent.transition_TurnToFacePrey : EEvent.transition_MoveToDisturbance;
				break;

			default:	// Shutdown the state.
				enemyShip.m_State = EState.none;
				return true;
		}

		return false;	// Proc functions return false unless the event is uncaught.
	}
예제 #20
0
파일: CEnemyShip.cs 프로젝트: nulhax/VOID
	static bool Proc_TurnToFacePrey(CEnemyShip enemyShip)
	{
		switch (enemyShip.m_Event)
		{
			case EEvent.none:	// Process the state.
				if (enemyShip.state_LookingAtTarget)	// Todo: Raycast check if there is a line of sight to the prey.
					enemyShip.m_Event = EEvent.transition_AttackPrey;
				break;

			default:	// Shutdown the state.
				enemyShip.m_State = EState.none;
				return true;
		}

		return false;	// Proc functions return false unless the event is uncaught.
	}
예제 #21
0
파일: CEnemyShip.cs 프로젝트: nulhax/VOID
	static bool Init_Travel(CEnemyShip enemyShip)
	{
		if (enemyShip.m_State != EState.none) Debug.LogError("CEnemyShip: State should be null when initialising a new state!");

		// Initialise the state.
		/*Consume event			*/enemyShip.m_Event = EEvent.none;
		/*Target disturbance?	*/enemyShip.state_TargetDisturbance = false;
		/*Move to target?		*/enemyShip.state_MoveToTarget = false;
		/*Handle prey target	*/enemyShip.state_Prey = null;
		/*Set state				*/enemyShip.m_State = EState.travelling;

		return true;	// Init functions always return true.
	}