Ejemplo n.º 1
0
    public virtual void Init()
    {
        // Cache the usual suspects
        iRigid      = GetComponent <Rigidbody>();
        iGameobject = gameObject;
        iTransform  = transform;

        // Add default keyboard input
        default_input = iGameobject.GetComponent <Keyboard_Input>();

        // Cache a reference to player controller
        PlayerController = iGameobject.GetComponent <BasePlayerManager>();

        // Call base class init
        PlayerController.Init();

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

        // See if we cant find an engine sound source, if we need to
        if (engineSoundSource == null)
        {
            engineSoundSource = iGameobject.GetComponent <AudioSource>();
        }
    }
    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;
    }
Ejemplo n.º 3
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;

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

        // set up the data for our player
        myDataManager = myPlayerManager.GetDataManager();
        myDataManager.SetName("Player1");
        myDataManager.SetHealth(3);

        isFinished = false;

        // get a ref to the player manager
        GameController_Plt2D.Instance.UpdateLivesP1(myDataManager.GetHealth());
    }
Ejemplo n.º 4
0
    public void InitThis()
    {
        // Cache our transform
        iTransform = transform;

        // Cache our gameobject
        iGameobject = gameObject;

        if (weaponControl == null)
        {
            // Try to find weapon controller on this gameObject
            weaponControl = iGameobject.GetComponent <StandardWeaponSlotController>();
        }

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

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

        iDatamanager = iPlayerManager.DataManager;
        iDatamanager.SetName("Enemy");
        iDatamanager.SetHealth(ThisEnemyStrength);

        _canFire = true;
        didInit  = true;
    }
Ejemplo n.º 5
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;
    }
Ejemplo n.º 6
0
 private void Start()
 {
     UIcontroller = FindObjectOfType <UIManager>();
     NPCdata      = FindObjectsOfType <BaseNPC>().ToList();
     playerdata   = GameObject.FindWithTag("主角").GetComponent <BasePlayerManager>();
     DialogueUI   = GameObject.FindWithTag("UI").transform.Find("對話視窗").gameObject;
     DialogueUI.SetActive(UIcontroller.Dia_status);
 }
Ejemplo n.º 7
0
 void SetupPlayer()
 {
     if (isLocalPlayer)
     {
         playerManager = GetComponent <BasePlayerManager>();
     }
     else
     {
     }
 }
    public override void Init()
    {
        if (myPlayerData == null)
        {
            myPlayerData = myGameObject.GetComponent <BasePlayerManager> ();
        }

        myDataManager = myPlayerData.DataManager;

        myDataManager.SetName("Amroo");
        myDataManager.SetHealth(150);
        didInit = true;
    }
Ejemplo n.º 9
0
    public override void Init()
    {
        if (iPlayerManager == null)
        {
            iPlayerManager = iGameobject.GetComponent <BasePlayerManager>();
        }

        iDataManager = iPlayerManager.DataManager;
        iDataManager.SetName("Player");
        iDataManager.SetHealth(3);

        didInit = true;
    }
Ejemplo n.º 10
0
    public override void Init()
    {
        // if a player manager is not set in the editor, let's try to find one
        if (myPlayerManager == null)
        {
            myPlayerManager = myGameObject.GetComponent <BasePlayerManager>();
        }

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

        didInit = true;
    }
Ejemplo n.º 11
0
    private void Start()
    {
        //取得玩家部分
        player        = GameObject.FindWithTag("主角");
        player_script = FindObjectOfType <BasePlayerManager>();
        player_sprite = player.GetComponent <SpriteRenderer>();

        //取得NPC部分
        NPC_Anime  = GetComponent <Animator>();
        NPC_sprite = GetComponent <SpriteRenderer>();

        //取得對話氣球
        ChooseTag = transform.GetChild(0).gameObject;
        ChooseTag.SetActive(false);
    }
Ejemplo n.º 12
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;
    }
Ejemplo n.º 13
0
    public virtual void Init()
    {
        // cache te usual suspects
        iRigid      = GetComponent <Rigidbody>();
        iGameobject = gameObject;
        iTransform  = transform;

        // add default keyboard input
        default_input = iGameobject.AddComponent <Keyboard_Input>();

        // cache a reference to the player controller
        iPlayerController = iGameobject.GetComponent <BasePlayerManager>();
        if (iPlayerController != null)
        {
            iPlayerController.Init();
        }
    }
Ejemplo n.º 14
0
    public virtual void Init()
    {
        myRigrdBody  = rigidbody;
        myTransform  = transform;
        myGameObject = gameObject;


        default_input = myGameObject.AddComponent <Keyboard_Input> ();



        myPlayerController = myGameObject.GetComponent <BasePlayerManager> ();

        if (myPlayerController != null)
        {
            myPlayerController.Init();
        }
    }
    public virtual void Init()
    {
        // cache the usual suspects
        myBody      = GetComponent <Rigidbody>();
        myGO        = gameObject;
        myTransform = transform;

        // add default keyboard input
        default_input = myGO.AddComponent <Keyboard_Input>();

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

        if (myPlayerController != null)
        {
            myPlayerController.Init();
        }
    }
Ejemplo n.º 16
0
    public virtual void Init()
    {
        myRigrdBody  = rigidbody;
        myGameObject = gameObject;
        myTransform  = transform;

        default_input      = myGameObject.AddComponent <Keyboard_Input>();
        myPlayerController = myGameObject.GetComponent <BasePlayerManager>();

        myPlayerController.Init();


        myRigrdBody.centerOfMass = new Vector3(0, -4f, 0);

        if (engineSound == null)
        {
            engineSound = myGameObject.GetComponent <AudioSource>();
        }
    }
Ejemplo n.º 17
0
    // main logic

    public override void Init()
    {
        base.Init();

        // add default keyboard input
        if (!default_input)
        {
            default_input = myGO.AddComponent <Keyboard_Input> ();
        }

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

        if (myPlayerController != null)
        {
            myPlayerController.Init();
        }
    }
Ejemplo n.º 18
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);
    }
Ejemplo n.º 19
0
    public override void Init()
    {
        Debug.Log("CarController_TB 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
        default_input = myGO.GetComponent <Keyboard_Input>();

        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, -6.5f, 0);

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

        AddBattleController();

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

        // 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();
        }

        isGameRunning = true;

        // store respawn point
        respawnPoint    = myTransform.position;
        respawnRotation = myTransform.eulerAngles;

        MakeVulnerable();

        // grab volume from sound controller for our engine sound
        GetComponent <AudioSource>().volume = BaseSoundController.Instance.volume;
    }
    public virtual void Init()
    {
        Debug.Log("BaseVehicle Init called.");

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

        // add default keyboard input
        if (myGO.GetComponent <Keyboard_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, -4f, 0);

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

        // now lets copy over our friction and suspension values to the wheels (keeping these values in one place
        // rather than having to change them on each wheel is a neater way to work!)

        // set up curves for front and sideways values

        WheelFrictionCurve curveF = new WheelFrictionCurve();

        curveF.extremumSlip   = forwardFrictionExtremumSlip;
        curveF.extremumValue  = forwardFrictionExtremumValue;
        curveF.asymptoteSlip  = forwardFrictionAsymptoteSlip;
        curveF.asymptoteValue = forwardFrictionAsymptoteValue;
        curveF.stiffness      = forwardFrictionStiffnessFactor;

        WheelFrictionCurve curveS = new WheelFrictionCurve();

        curveS.extremumSlip   = sidewaysFrictionExtremumSlip;
        curveS.extremumValue  = sidewaysFrictionExtremumValue;
        curveS.asymptoteSlip  = sidewaysFrictionAsymptoteSlip;
        curveS.asymptoteValue = sidewaysFrictionAsymptoteValue;
        curveS.stiffness      = sidewaysFrictionStiffnessFactor;

        // set up JointSpring for the suspension settings
        JointSpring suspensionJointSpring = new JointSpring();

        suspensionJointSpring.damper = suspensionDamper;
        suspensionJointSpring.spring = suspensionSpring;

        // front left
        frontWheelLeft.mass   = wheelMass;
        frontWheelLeft.radius = wheelRadius;

        frontWheelLeft.suspensionDistance = suspensionDistance;
        frontWheelLeft.suspensionSpring   = suspensionJointSpring;

        frontWheelLeft.forwardFriction  = curveF;
        frontWheelLeft.sidewaysFriction = curveS;

        // front right
        frontWheelRight.mass   = wheelMass;
        frontWheelRight.radius = wheelRadius;

        frontWheelRight.suspensionDistance = suspensionDistance;
        frontWheelRight.suspensionSpring   = suspensionJointSpring;

        frontWheelRight.forwardFriction  = curveF;
        frontWheelRight.sidewaysFriction = curveS;

        // rear left
        rearWheelLeft.mass   = wheelMass;
        rearWheelLeft.radius = wheelRadius;

        rearWheelLeft.suspensionDistance = suspensionDistance;
        rearWheelLeft.suspensionSpring   = suspensionJointSpring;

        rearWheelLeft.forwardFriction  = curveF;
        rearWheelLeft.sidewaysFriction = curveS;

        // rear right
        rearWheelRight.mass   = wheelMass;
        rearWheelRight.radius = wheelRadius;

        rearWheelRight.suspensionDistance = suspensionDistance;
        rearWheelRight.suspensionSpring   = suspensionJointSpring;

        rearWheelRight.forwardFriction  = curveF;
        rearWheelRight.sidewaysFriction = curveS;

        Debug.Log("BaseVehicle wheels setup and Init() complete.");
    }