Exemplo n.º 1
0
    // main logic
    public override void Init()
    {
        base.Init();

        didInit = false;

        if (weaponControl == null)
        {
            // try to find weapon controller on this gameobject
            weaponControl = myGO.GetComponent <Standard_SlotWeaponController> ();
        }

        if (rendererToTestAgainst == null)
        {
            // we need a renderer to find out whether or not we are on-screen
            rendererToTestAgainst = myGO.GetComponentInChildren <Renderer> ();
        }

        // if a player manager is not set in the editor, let's try to find one
        if (myPlayerManager == null)
        {
            myPlayerManager = myGO.AddComponent <BasePlayerManager> ();
        }

        myDataManager = myPlayerManager.GetDataManager();
        myDataManager.SetName("Enemy");
        myDataManager.SetHealth(thisEnemyStrength);

        canFire = true;
        didInit = true;
    }
    public void Init()
    {
        // cache our transform
        myTransform = transform;

        // cache our gameObject
        myGO = gameObject;

        if (weaponControl == null)
        {
            // try to find weapon controller on this gameobject
            weaponControl = myGO.GetComponent <Standard_SlotWeaponController>();
        }

        if (rendererToTestAgainst == null)
        {
            // we need a renderer to find out whether or not we are on-screen, so let's try and find one
            // in our children if we don't already have one set in the editor
            rendererToTestAgainst = myGO.GetComponentInChildren <Renderer>();
        }

        // if a player manager is not set in the editor, let's try to find one
        if (myPlayerManager == null)
        {
            myPlayerManager = myGO.AddComponent <BasePlayerManager>();
        }

        myDataManager = myPlayerManager.DataManager;
        myDataManager.SetName("Enemy");
        myDataManager.SetHealth(thisEnemyStrength);

        canFire = true;
        didInit = true;
    }
Exemplo n.º 3
0
    public override void Init()
    {
        // hide the invulnerability shield(!)
        if (!godMode)
        {
            MakeVulnerable();
        }
        else
        {
            MakeInvulnerable();
        }

        // get a ref to the weapon controller
        weaponControl = myGO.GetComponent <Standard_SlotWeaponController>();

        // tell weapon control who we are (so all weapon control can tell projectiles who sent them)
        weaponControl.SetOwner(ownerID);

        // if a player manager is not set in the editor, let's try to find one
        if (myPlayerManager == null)
        {
            myPlayerManager = myGO.GetComponent <BasePlayerManager>();
        }

        myDataManager = myPlayerManager.DataManager;
        myDataManager.SetName("Player");
        myDataManager.SetHealth(3);

        // update UI lives
        if (ownerID == 1)
        {
            // if our owner ID is 1, we must be player 1
            GameController_IP.Instance.UpdateLivesP1(myDataManager.GetHealth());
        }
        else
        {
            // we are player 2, so set that UI instead
            GameController_IP.Instance.UpdateLivesP2(myDataManager.GetHealth());
        }

        if (isMouseControlled)
        {
            // if we are going to use mouse controls, add a mouse input controller
            mouse_input = gameObject.AddComponent <Mouse_Input>();
        }

        didInit = true;
    }
Exemplo n.º 4
0
    // main logic
    public override void Init()
    {
        base.Init();

        // do god mode, if needed)
        if (!godMode)
        {
            MakeVulnerable();
        }
        else
        {
            MakeInvulnerable();
        }

        // start out with no control from the player
        canControl = false;

        // get a ref to the weapon controller
        weaponControl = myGO.GetComponent <Standard_SlotWeaponController> ();

        // if a player manager is not set in the editor, let's try to find one
        if (myPlayerManager == null)
        {
            myPlayerManager = myGO.GetComponent <PlayerManager_Tank> ();
        }

        // set up the data for our player
        myDataManager = myPlayerManager.DataManager_Tank;
        myDataManager.SetName("Player");
        myDataManager.SetHealth(3);
        myDataManager.SetDetaleHealth(100);
        myDataManager.SetProtection(0.5f);

        isFinished = false;

        // get a ref to the player manager
        GameController_Tank.Instance.UpdateLivesP1(myDataManager.GetHealth());
        GameController_Tank.Instance.UpdateLivesDetaleP1(myDataManager.GetDetaleHealth());
    }
Exemplo n.º 5
0
    public override void Init()
    {
        Debug.Log("CarController_MVD Init called.");

        // cache the usual suspects
        myBody      = GetComponent <Rigidbody>();
        myGO        = gameObject;
        myTransform = transform;

        // allow respawning from the start
        canRespawn = true;

        // save our accelMax value for later, incase we need to change it to
        // do AI catch up
        originalAccelMax = accelMax;

        // add default keyboard input if we don't already have one
        if (default_input == null)
        {
            default_input = myGO.AddComponent <Keyboard_Input>();
        }

        // cache a reference to the player controller
        myPlayerController = myGO.GetComponent <BasePlayerManager>();

        // call base class init
        myPlayerController.Init();

        // with this simple vehicle code, we set the center of mass low to try to keep the car from toppling over
        myBody.centerOfMass = new Vector3(0, -3.5f, 0);

        // see if we can find an engine sound source, if we need to
        if (engineSoundSource == null)
        {
            engineSoundSource = myGO.GetComponent <AudioSource>();
        }

        AddRaceController();

        // reset our lap counter
        raceControl.ResetLapCounter();

        // get a ref to the weapon controller
        weaponControl = myGO.GetComponent <Standard_SlotWeaponController>();

        // if a player manager is not set in the editor, let's try to find one
        if (myPlayerManager == null)
        {
            myPlayerManager = myGO.GetComponent <BasePlayerManager>();
        }

        // cache ref to data manager
        myDataManager = myPlayerManager.DataManager;

        // set default data
        myDataManager.SetName("Player");
        myDataManager.SetHealth(startHealthAmount);

        if (isAIControlled)
        {
            // set our name to an AI player
            myDataManager.SetName("AIPlayer");

            // set up AI
            InitAI();
        }

        //GameController_MVD.Instance.UpdateWrongWay(false);
    }