コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        #region generation
        //float width = 2f * tileScale;
        //float height = Mathf.Sqrt(3f) * tileScale;
        //float downShift = 0.08f;
        //Vector3 centerOffset = new Vector3((gridWidth - 1) * width - (gridWidth - 1) * width * .25f, 0f, (gridHeight - 1) * height + height / 2f);
        //for (int x = 0; x < gridWidth; ++x)
        //{
        //    for (int z = 0; z < gridHeight; ++z)
        //    {
        //        GameObject newTile = Instantiate(theTilePrefab) as GameObject;
        //        GameObject tileMesh = newTile.transform.GetChild(0).gameObject;
        //        newTile.transform.position = new Vector3(x * width - x * width * .25f, -downShift, z * height + (x % 2 == 0 ? 0 : height / 2f)) - centerOffset * .5f;
        //        newTile.transform.localScale = new Vector3(tileScale, 1f, tileScale);
        //        newTile.transform.parent = gameObject.transform;
        //        tileMesh.GetComponent<MeshRenderer>().material = theTileMat;
        //        hexGrids.Add(newTile);
        //    }
        //}

        //PrefabUtility.SaveAsPrefabAsset(gameObject, "Assets/Prefabs/Grids2.prefab");
        #endregion
        if (visited.Count != hexGrids.Count)
        {
            visited = new List <bool>();
            for (int x = 0; x < hexGrids.Count; ++x)
            {
                visited.Add(false);
            }
        }
        manager = GameObject.Find("GameManager").GetComponent <HexGameManager>();
        UpdateGameManager();
    }
コード例 #2
0
    private void Start()
    {
        //All players except yourself will be assigned the 'Player' layer, so that they can be shot, except you.
        if (!photonView.IsMine)
        {
            gameObject.layer = 11;
            gameObject.tag   = "Player";
        }
        else
        {
            divisionUIParent = GameObject.Find("DivisionUI"); //Set the division script to the player GameObject
            switch (GameData.GetDivision())
            {
            case GameData.Division.P_Damage:
                p_Division = gameObject.AddComponent <Damage>();
                divisionUIParent.transform.Find("DamageUI").gameObject.SetActive(true);
                p_Division.Init(7.5f, 8.5f, 450f);
                GameObject.Find("WeaponScrollUI").GetComponent <WeaponUI>().SetRifleSprite("Damage");
                break;

            case GameData.Division.P_Flank:
                p_Division = gameObject.AddComponent <Flank>();
                divisionUIParent.transform.Find("FlankUI").gameObject.SetActive(true);
                p_Division.Init(10f, 5f, 500f);
                GameObject.Find("WeaponScrollUI").GetComponent <WeaponUI>().SetRifleSprite("Flank");
                break;

            case GameData.Division.P_Tank:
                p_Division = gameObject.AddComponent <Tank>();
                divisionUIParent.transform.Find("TankUI").gameObject.SetActive(true);
                p_Division.Init(5f, 8f, 400f);
                GameObject.Find("WeaponScrollUI").GetComponent <WeaponUI>().SetRifleSprite("Tank");
                break;
            }

            sceneCam = GameObject.Find("Cameras").transform.Find("GameEnd").gameObject;
            if (sceneCam != null)
            {
                sceneCam.SetActive(false);
            }

            t_currHP = GameObject.Find("CurrHP").GetComponent <TextMeshProUGUI>();
            GameObject.Find("BaseHP").GetComponent <TextMeshProUGUI>().text = t_currHP.text = ((int)maxHealth).ToString();
        }

        //Set my player camera to true
        camParent.SetActive(photonView.IsMine);

        //Camera.main.gameObject.SetActive(false);
        playerRig    = GetComponent <Rigidbody>();
        weaponOrigin = weaponParent.localPosition;

        //Set health
        currHealth = maxHealth;

        manager = GameObject.Find("GameManager").GetComponent <HexGameManager>();
        loadout = GetComponent <PlayerLoadout>();

        if (photonView.IsMine)
        {
            teamName = manager.GetLocalPlayerTeam();
            photonView.RPC("SyncTeamName", RpcTarget.AllBuffered, teamName, GameData.playerName);
            TextMeshProUGUI teamText = GameObject.Find("Team").GetComponent <TextMeshProUGUI>();
            teamText.text  = teamName + " Team";
            teamText.color = teamName == "Blue" ? new Color(0f, 1f, 1f) : new Color(1f, 0f, 0f);
        }

        hpBar       = GameObject.Find("HpBar").transform;
        currAmmo    = GameObject.Find("CurrAmmo").GetComponent <TextMeshProUGUI>();
        baseAmmo    = GameObject.Find("BaseAmmo").GetComponent <TextMeshProUGUI>();
        currHpScale = 1f;

        crosshair = GameObject.Find("Crosshair");

        isMoving   = false;
        assistList = new List <int>();
    }
コード例 #3
0
 // Start is called before the first frame update
 void Start()
 {
     manager = GameObject.Find("GameManager").GetComponent <HexGameManager>();
     updated = false;
 }