Exemple #1
0
    void PlayerCreate()
    {
        GameObject tmpObj = null;

        string[] spos   = PlayerDataManagement.Singleton().NowPlayerData.SavePos.Split('/');
        Vector3  tmpPos = new Vector3(float.Parse(spos[0]), float.Parse(spos[1]), float.Parse(spos[2]));

        Debug.Log(tmpPos);
        tmpObj = Instantiate(Player, tmpPos, Quaternion.identity) as GameObject;
    }
    public static PlayerDataManagement Singleton()
    {
        if (!SingletonInstance)
        {
            GameObject TempSingletonInstance = new GameObject();
            SingletonInstance = TempSingletonInstance.AddComponent <PlayerDataManagement>();

            DontDestroyOnLoad(SingletonInstance);
        }

        return(SingletonInstance);
    }
Exemple #3
0
    void On_Respawn()
    {
        float spawnTime = 3.0f;

        PlayerDataManagement.Singleton().NowPlayerData.Health = 100;
        PlayerDataManagement.Singleton().life = true;
        while (spawnTime < 0)
        {
            spawnTime = spawnTime - Time.deltaTime;
        }
        Reset.SetActive(PlayerDataManagement.Singleton().life);
    }
    void OnCollisionEnter(Collision col)
    {
        int HP       = PlayerDataManagement.Singleton().NowPlayerData.Health;
        int Critical = Random.Range(3, 9);

        if (col.gameObject.CompareTag("Enemy"))
        {
            PlayerDataManagement.Singleton().NowPlayerData.Health = HP - (PlayerDataManagement.Singleton().NowPlayerData.Damage + (PlayerDataManagement.Singleton().NowPlayerData.Health / Critical));
            if (PlayerDataManagement.Singleton().NowPlayerData.Health < 0)
            {
                PlayerDataManagement.Singleton().life = false;
                obj.SetActive(PlayerDataManagement.Singleton().life);
            }
        }
    }
    private void OnTriggerEnter(Collider col)
    {
        int     damage = PlayerDataManagement.Singleton().NowPlayerData.Damage;
        Respawn rsp    = new Respawn();

        if (col.tag == "Attack")
        {
            if (HP <= 0)
            {
                OnDestroy();
                HP = 100.0f;
            }
            HP = HP - damage;
            Debug.Log(HP);
        }
    }
Exemple #6
0
    // Use this for initialization
    void Start()
    {
        rb               = this.GetComponentInChildren <Rigidbody>();
        playerData       = GameObject.Find("PlayerData").GetComponent <PlayerDataManagement>();
        startingPosition = transform.localPosition;
        AIBoundary       = new Boundary(AIBoundaryHolder.GetChild(0).localPosition.z,
                                        AIBoundaryHolder.GetChild(1).localPosition.z,
                                        AIBoundaryHolder.GetChild(2).localPosition.x,
                                        AIBoundaryHolder.GetChild(3).localPosition.x);

        PuckBoundary = new Boundary(PuckBoundaryHolder.GetChild(0).localPosition.z,
                                    PuckBoundaryHolder.GetChild(1).localPosition.z,
                                    PuckBoundaryHolder.GetChild(2).localPosition.x,
                                    PuckBoundaryHolder.GetChild(3).localPosition.x);
        Debug.Log("puck position: " + puck.transform.localPosition);
        Debug.Log("AI paddle position: " + transform.localPosition);
        Debug.Log("AIboundary up:" + AIBoundary.Up + "\nAIboundary down:" + AIBoundary.Down + "\nAIboundary left: " + AIBoundary.Left + "\nAIboundary right: " + AIBoundary.Right);
        Debug.Log("Puckboundary up:" + PuckBoundary.Up + "\nPuckboundary down:" + PuckBoundary.Down + "\nPuckboundary left: " + PuckBoundary.Left + "\nPuckboundary right: " + PuckBoundary.Right);
    }
 // Use this for initialization
 void Start()
 {
     rb             = player1.GetComponent <Rigidbody>();
     playerData     = GameObject.Find("PlayerData").GetComponent <PlayerDataManagement>();
     playerBoundary = new Boundary(BoundaryHolder.GetChild(0).localPosition.z,
                                   BoundaryHolder.GetChild(1).localPosition.z,
                                   BoundaryHolder.GetChild(2).localPosition.x,
                                   BoundaryHolder.GetChild(3).localPosition.x);
     // Debug.Log ("boundary up:" + playerBoundary.Up+"\nboundary down:" + playerBoundary.Down+"\nboundary left: " + playerBoundary.Left+"\nboundary right: "+ playerBoundary.Right);
     // Debug.Log("x: "+player1.transform.eulerAngles.x+ "y: "+player1.transform.eulerAngles.y+ "z: "+player1.transform.eulerAngles.z);
     positionText.enabled = true;
     SizeUpBtn.SetActive(true);
     SizeDownBtn.SetActive(true);
     RotateLeftBtn.SetActive(true);
     RotateRightBtn.SetActive(true);
     RestartBtn.SetActive(false);
     FixBtn.SetActive(true);
     // alignToPlane(player1);
     // alignToPlane(player2);
     // // alignToPlane(puck);
     // Debug.Log("puck position: "+ puckposition);
     ScoreRecord.enabled = true;
     showScore();
 }
Exemple #8
0
 public void OnClickOk()
 {
     PlayerDataManagement.Singleton().CreateData(SetName.text);
 }
Exemple #9
0
 public void OnClickLoadButton()
 {
     PlayerDataManagement.Singleton().LoadData();
 }
 // Use this for initialization
 void Start()
 {
     playerData = GameObject.Find("PlayerData").GetComponent <PlayerDataManagement>();
 }