コード例 #1
0
    // Use this for initialization
    void Start()
    {
        ballControl = GetComponent <BallControl>();
        //PathToFollow
        pathToFollow = GameObject.FindWithTag("AIPath").GetComponent <Path>();
        //PathFollower
        AITarget pFollower = (AITarget)Instantiate(aiTargetPrefab);

        pFollower.GetComponent <PathFollower>().path = pathToFollow;
        pFollower.stupidness = stupidness;
        pFollower.GetComponent <Patroller>().target = this.gameObject;
        target = pFollower;
    }
コード例 #2
0
ファイル: BallLocal.cs プロジェクト: pandey623/SanicBall-UNET
        private void Start()
        {
            Up = Vector3.up;

            //Set up drifty smoke
//            smoke = Instantiate(prefabs.Smoke);
//            smoke.target = this;
//            smoke.DriftAudio = sounds.Brake;

            //Grab reference to Rigidbody
            rb = GetComponent <Rigidbody>();
            //Set angular velocity (This is necessary for fast)
            rb.maxAngularVelocity = 1000f;

            //Set object name
            gameObject.name = nickname;

            //Set character
            if (CharacterId >= 0 && CharacterId < Data.ActiveData.Characters.Length)
            {
                SetCharacter(Data.ActiveData.Characters[CharacterId]);
            }

            //Create objects and components based on ball type
            if (type == BallType.Player)
            {
                IBallCamera camera;
                OmniCamera  newCam = Instantiate(prefabs.Camera);
                newCam.Target   = rb;
                newCam.CtrlType = ctrlType;
                PivotCamera oldCam = Instantiate(prefabs.OldCamera);
                oldCam.Target   = rb;
                oldCam.CtrlType = ctrlType;

                //Create camera
                if (Data.ActiveData.GameSettings.useOldControls)//camara vieja
                {
                    camera = oldCam;
                    newCam.gameObject.SetActive(false);
                    ((PivotCamera)camera).UseMouse = (ctrlType == ControlType.Keyboard);
                }
                else
                {
                    camera = newCam;
                    oldCam.gameObject.SetActive(false);
                }
                camera.Target   = rb;
                camera.CtrlType = ctrlType;
                if (CameraCreated != null)
                {
                    CameraCreated(this, new CameraCreationArgs(camera, oldCam.gameObject, newCam.gameObject));
                }
            }
            if (type == BallType.LobbyPlayer)
            {
                //Make the lobby camera follow this ball
                var cam = FindObjectOfType <LobbyCameraLocal>();
                if (cam)
                {
                    cam.AddBall(this);
                }
            }
            if ((type == BallType.Player || type == BallType.LobbyPlayer))
            {
                //Create input component
                input = gameObject.AddComponent <BallControlInputLocal>();
            }
            if (type == BallType.AI)
            {
                //Create AI component
                var ai = gameObject.AddComponent <BallControlAILocal>();
                ai.pathToFollow = FindObjectOfType <Path>();

                //Create target for the AI
                AITarget pFollower = Instantiate(prefabs.AiTarget);
                pFollower.GetComponent <PathFollower>().path = ai.pathToFollow;
                pFollower.stupidness = ai.stupidness;
                pFollower.GetComponent <Patroller>().target = gameObject;
                ai.target = pFollower;
            }
        }
コード例 #3
0
ファイル: Ball.cs プロジェクト: pandey623/SanicBall-UNET
        public void RpcInit(BallType type, ControlType ctrlType, int characterId, string nickname)
        {
            this.type        = type;
            this.ctrlType    = ctrlType;
            this.characterId = characterId;
            this.nickname    = nickname;


            Debug.Log("We re running RPCInit character is _ " + this.characterId);

            Up = Vector3.up;

            //Set up drifty smoke
            smoke            = Instantiate(prefabs.Smoke);
            smoke.target     = this;
            smoke.DriftAudio = sounds.Brake;

            //Grab reference to Rigidbody
            rb = GetComponent <Rigidbody>();
            //Set angular velocity (This is necessary for fast)
            rb.maxAngularVelocity = 1000f;

            //Set object name
            gameObject.name = nickname;

            //Set character
            if (CharacterId >= 0 && CharacterId < Data.ActiveData.Characters.Length)
            {
                SetCharacter(Data.ActiveData.Characters[CharacterId]);
            }

            //Create objects and components based on ball type
            if (type == BallType.Player && cameraBall == null && isLocalPlayer)
            {
                OmniCamera newCam = Instantiate(prefabs.Camera);
                newCam.Target   = rb;
                newCam.CtrlType = ctrlType;
                PivotCamera oldCam = Instantiate(prefabs.OldCamera);
                oldCam.Target   = rb;
                oldCam.CtrlType = ctrlType;

                //Create camera
                if (Data.ActiveData.GameSettings.useOldControls)
                {
                    cameraBall = oldCam;
                    newCam.gameObject.SetActive(false);

                    ((PivotCamera)cameraBall).UseMouse = ctrlType == ControlType.Keyboard;
                }
                else
                {
                    cameraBall = newCam;
                    oldCam.gameObject.SetActive(false);
                }
                cameraBall.Target   = rb;
                cameraBall.CtrlType = ctrlType;

                if (CameraCreatedEvent != null)
                {
                    CameraCreatedEvent(this, new CameraCreationArgs(cameraBall, oldCam.gameObject, newCam.gameObject));
                }
            }
            if (type == BallType.LobbyPlayer)
            {
                //Make the lobby camera follow this ball
                var cam = FindObjectOfType <LobbyCamera>();
                if (cam)
                {
                    cam.AddBall(this);
                }
            }
            if ((type == BallType.Player || type == BallType.LobbyPlayer && isLocalPlayer) && input == null)
            {
                //Create input component
                input = gameObject.AddComponent <BallControlInput>();
            }
            if (type == BallType.AI)
            {
                //Create AI component
                var ai = gameObject.AddComponent <BallControlAI>();
                ai.pathToFollow = FindObjectOfType <Path>();

                //Create target for the AI
                AITarget pFollower = Instantiate(prefabs.AiTarget);
                pFollower.GetComponent <PathFollower>().path = ai.pathToFollow;
                pFollower.stupidness = ai.stupidness;
                pFollower.GetComponent <Patroller>().target = gameObject;
                ai.target = pFollower;
            }

            if (!isServer)
            {
            }
        }