コード例 #1
0
 public virtual void Awake()
 {   // point static value to this script, works if there are only one script running in scene
     if (_instance == null)
     {
         _instance = this;
     }
 }
        public virtual void OnEnable()
        {
            CPC = (Player_Controller_RPG)target;

            serOBJ = new SerializedObject(target);
            PMB    = serOBJ.FindProperty("PlayerMoveBehivior"); //  find serializable enum
            PTB    = serOBJ.FindProperty("PlayerTurnBehivior");
            //camOBJ = serOBJ.FindProperty("Cam_Center_Point"); // 19.02.15 auto search for cam obj, not really need to show this any more
        }
コード例 #3
0
        // Start is called before the first frame update
        void Start()
        {
            cc = Camera_Controller.Instance;                   // camera instance
            playerController = Player_Controller_RPG.Instance; // player instance

            if (cc == null)
            {
                Debug.LogError("There is no camera controller in the scene!!");
            }
            else
            {
                playerCam = cc.Cam_Obj.GetComponent <Camera>();
            }
            if (playerCam == null)
            {
                Debug.LogError("There is no camera controller in camera controller!!");
            }

            if (playerController == null)
            {
                Debug.LogError("There is no player controller in scene");
                return;
            }
            // read player controller script attached object
            playerOBJ = playerController.gameObject;
            // looking for ai script
            pathRichAI = playerOBJ.GetComponent <Pathfinding.RichAI>();
            pathAIPath = playerOBJ.GetComponent <Pathfinding.AIPath>();
            pathAILerp = playerOBJ.GetComponent <Pathfinding.AILerp>();
            // disable ai because in rpg mode it will conflict with the control
            aiOn = false;
            if (pathRichAI != null)
            {
                pathRichAI.enabled = false;
            }
            else if (pathAIPath != null)
            {
                pathAIPath.enabled = false;
            }
            else if (pathAILerp != null)
            {
                pathAILerp.enabled = false;
            }

            rightClickInfoType = RC_InfoType.None;
        }
コード例 #4
0
        // Use this for initialization
        public virtual void Start()
        {
            if (!isThisScriptAsigned)
            {
                isThisScriptAsigned = true;
                _instance           = this;
            }
            playerRigidbody             = GetComponent <Rigidbody>();
            playerRigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; //freeze rigidbody's rotation to prevent fall down to floor
                                                                                                                       //playerRigidbody.drag = Mathf.Infinity;
            playerRigidbody.angularDrag = Mathf.Infinity;                                                              //prevant character keep turn not stop after finish rotation
            anim = GetComponent <Animator>();
            cc   = Camera_Controller.Instance;
            if (Cam_Center_Point == null)
            {
                Cam_Center_Point = cc.gameObject;
            }
            //playerCam = Cam_Center_Point.GetComponent<Camera_Controller>().Cam_Obj.GetComponent<Camera>();

            newYAng               = transform.eulerAngles.y; //	initialize value in first run
            layerMaskFloor        = LayerMask.GetMask("Floor");
            layerMaskObstacles    = LayerMask.GetMask("Obstacles");
            layerMaskHeightAdjust = LayerMask.GetMask("HeightAdjust");
        }