상속: MonoBehaviour
예제 #1
0
    //destoryed player/object
    private void OnDisable()
    {
        Destroy(playerUIInstance);
        if (playerUIInstance == null)
        {
            Debug.Log("destroyed UI");
        }
        else
        {
            Debug.Log("noooo");
        }

        // Debug.Log((playerUIInstance.active=false)?"y":"n");

        // NetworkServer.Destroy(playerUIInstance);

        if (sceneCamera != null)
        {
            sceneCamera.gameObject.SetActive(true);
            Debug.Log("sceneCam active");
        }

        GameManager1.UnregisterPlayer(transform.name);

        // Destroy(this.gameObject);
    }
예제 #2
0
 private void Start()
 {
     Instance = this;
     serverMenu.SetActive(false);
     connectMenu.SetActive(false);
     DontDestroyOnLoad(gameObject);
 }
예제 #3
0
 void Damaging()
 {
     if (dmgTime == true)
     {
         GameManager1.WallDmg(10);
     }
 }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        _gm          = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager1>();
        _videoPlayer = GetComponent <VideoPlayer>();
        if (_videoPlayer == null)
        {
            _videoPlayer = gameObject.AddComponent <VideoPlayer>();
        }

        _audioSource = GetComponent <AudioSource>();
        if (_audioSource == null)
        {
            _audioSource = gameObject.AddComponent <AudioSource>();
        }

        _videoPlayer.playOnAwake            = false;
        _videoPlayer.clip                   = goodClip;
        _videoPlayer.isLooping              = true;
        _videoPlayer.renderMode             = VideoRenderMode.MaterialOverride;
        _videoPlayer.targetMaterialRenderer = GetComponent <Renderer>();
        _videoPlayer.targetMaterialProperty = "_MainTex";
        _videoPlayer.audioOutputMode        = VideoAudioOutputMode.AudioSource;
        _audioSource.spatialize             = true;
        _audioSource.spatialBlend           = 1;
        _audioSource.maxDistance            = 50;
        _audioSource.minDistance            = 2;
        _videoPlayer.SetTargetAudioSource(0, _audioSource);
        _currentFrame = 0;
    }
예제 #5
0
    // Use this for initialization
    void Start()
    {
        _cm = GetComponent <ChildManager>();
        _gm = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager1>();

        GameManager1.kids.Add(this);
    }
예제 #6
0
 // GetComponent Function
 //This Function is mainly used for Get Component
 void GetComponentFunction()
 {
     if (_Rgbd == null)
     {
         _Rgbd = GetComponent <Rigidbody>();
     }
     if (_anim == null)
     {
         _anim = GetComponentInChildren <Animator>();
     }
     if (_capCollider == null)
     {
         _capCollider = GetComponent <CapsuleCollider>();
     }
     if (_navMeshAgent == null)
     {
         _navMeshAgent = GetComponent <NavMeshAgent>();
     }
     if (_gameManager1 == null)
     {
         _gameManager1 = GameObject.FindGameObjectWithTag("GameManager1").GetComponent <GameManager1>();
     }
     if (_PopUpDamage == null)
     {
         Debug.LogError("Please Added the Pop UP Damage Effect");
     }
     if (_SwordEffectObject == null)
     {
         Debug.Log("Please Add The Effect Object to the  Script");
     }
 }
예제 #7
0
    public void CmdPlayerShot(string _playerID, int _damage)
    {
        Debug.Log(_playerID + "has been shot");
        Player _player = GameManager1.GetPlayer(_playerID);

        _player.RpcTakeDamage(_damage);
    }
예제 #8
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
예제 #9
0
 // Use this for initialization
 void Start()
 {
     GAME = GameObject.Find("_GAMEMANAGER").gameObject.GetComponent <GameManager1> ();
     if (GAME == null)
     {
         Debug.LogError("GAME MANAGER NOT FOUND");
     }
 }
예제 #10
0
 // Start is called before the first frame update
 void Start()
 {
     lifes           = 3;
     nextFire        = 0.0f;
     canMoveAndShoot = false;
     playerRB        = gameObject.GetComponent <Rigidbody>();
     gameManager     = GameObject.Find("GameManager1").GetComponent <GameManager1>();
 }
예제 #11
0
    public override void OnStartClient()
    {
        base.OnStartClient();
        string netid  = GetComponent <NetworkIdentity>().netId.ToString();
        Player player = GetComponent <Player>();

        GameManager1.RegisterPlayer(netid, player);
    }
예제 #12
0
    // Start is called before the first frame update
    void Start()
    {
        button      = GetComponent <Button>();
        gameManager = GameObject.Find("GameManager").GetComponent <GameManager1>();


        button.onClick.AddListener(clickStart);
    }
예제 #13
0
 GameManager1 Game;                         //呼叫GameManager用?
 private void Start()
 {
     rb              = GetComponent <Rigidbody2D>();
     downRotation    = Quaternion.Euler(0, 0, -90);
     forwardRotation = Quaternion.Euler(0, 0, 35);
     Game            = GameManager1.Instance;
     rb.simulated    = false;
 }
예제 #14
0
    void Awake()
    {
        if (_instance == null)
        {
            _instance = this;
        }

        SettingResolutionProblem();
    }
예제 #15
0
    // Use this for initialization
    void Start()
    {
        bowl.SetActive(false);
        cube.SetActive(false);
        bear.SetActive(false);

        _player = GameObject.Find("Player").GetComponent <Player>();
        _gm     = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager1>();
    }
예제 #16
0
 void OnTriggerEnter2D(Collider2D hitInfo)
 {
     if (hitInfo.name == "ball2")
     {
         string wallName = transform.name;
         GameManager1.Score(wallName);
         hitInfo.gameObject.SendMessage("RestartGame", 1.0f, SendMessageOptions.RequireReceiver);
     }
 }
    public void CmdPlayerShot(string _playerID, float _damage)
    {
        UnityEngine.Debug.Log(_playerID + " has been shot");
        Player _player = GameManager1.GetPlayer(_playerID);

        _player.RpcTakeDamage(_damage);

        Destroy(this.gameObject);
    }
예제 #18
0
    //初始化地图
    public void InitMap()
    {
        gameManager1 = this.GetComponent <GameManager1>();

        mapHolder = new GameObject("Map").transform;

        for (int i = 0; i < cols; i++)
        {
            for (int j = 0; j < rows; j++)
            {
                if (i == 0 || j == 0 || i == cols - 1 || j == rows - 1) //外墙
                {
                    int        index = Random.Range(0, OutWallArray.Length);
                    GameObject go    = GameObject.Instantiate(OutWallArray[index], new Vector2(i, j), Quaternion.identity);
                    go.transform.SetParent(mapHolder);
                }
                else //地板
                {
                    int        index = Random.Range(0, FloorArray.Length);
                    GameObject go    = GameObject.Instantiate(FloorArray[index], new Vector2(i, j), Quaternion.identity);
                    go.transform.SetParent(mapHolder);
                }
            }
        }

        positionList.Clear();  //清空positionList
        for (int i = 2; i < cols - 2; i++)
        {
            for (int j = 2; j < rows - 2; j++)
            {
                positionList.Add(new Vector2(i, j));
            }
        }

        //创建障碍物 食物 敌人
        //创建障碍物
        int WallCount = Random.Range(minCountWall, maxCountWall + 1);

        InstantiateItems(WallCount, WallArray);


        //创建食物 2~level*2
        int FoodCount = Random.Range(2, gameManager1.level * 2 + 1);

        InstantiateItems(FoodCount, FoodArray);

        //创建敌人 level/2+1
        int EnemyCount = gameManager1.level / 2 + 1;

        InstantiateItems(EnemyCount, EnemyArray);

        //创建出口
        GameObject go1 = Instantiate(ExitPrefab, new Vector2(cols - 2, rows - 2), Quaternion.identity) as GameObject;

        go1.transform.SetParent(mapHolder);
    }
예제 #19
0
 // Start is called before the first frame update
 void Start()
 {
     gameManager = GameObject.Find("GameManager1").GetComponent <GameManager1>();
     fireRate    = 3.5f;
     moonLives   = 100;
     moveRight   = true;
     move        = false;
     hasArrived  = false;
     StartCoroutine(WaitAndShoot());
 }
예제 #20
0
    //public AudioClip[] audioClip;


    void Start()
    {
        spawn = transform.position;
        if (usesManager)
        {
            manager = manager.GetComponent <GameManager1>();
        }
        FindObjectOfType <AudioManager>().Play("BackgroundMusic");

        nextSceneToLoad = SceneManager.GetActiveScene().buildIndex + 1;
    }
예제 #21
0
 void SpawnManagers()
 {
     if (gameManager == null && itemdex == null)
     {
         Debug.LogError("no itemdex or gameManager assigned");
         return;
     }
     itemdexInstance     = Instantiate(itemdex);
     gameManagerInstance = Instantiate(gameManager);
     Debug.Log("successfully instantiated itemdex and gameManager");
 }
    void Start()
    {
        //player = GetComponent<Rigidbody>();
        player = GetComponent <Rigidbody2D>();

        PowerUpTimer   = 0;
        facingRight    = true;
        theGameManager = FindObjectOfType <GameManager1>();

        myAnimator = GetComponent <Animator>();
    }
예제 #23
0
 private void Awake()
 {
     if (instance != null)
     {
         Debug.LogError("More than one gamemanager" + transform.name);
     }
     else
     {
         instance = this;
     }
 }
예제 #24
0
 void Spawn2()
 {
     if (Spawning == true)
     {
         Instantiate(Enemies [1], SpawnPos, this.transform.rotation);
         EnLeft--;
         GameManager1 gm1 = GameObject.Find("GameManager").GetComponent <GameManager1>();
         gm1.EnemiesLeft = EnLeft;
         //SpawnPos = new Vector3 (this.transform.position.x + (Random.Range(-15,15)), this.transform.position.y, this.transform.position.z);
     }
 }
예제 #25
0
 void _MakeInstance()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
예제 #26
0
 void Awake()
 {
     if (Instance == null)
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
예제 #27
0
    private void Awake()
    {
        if (_instance == null)
        {
            _instance = this;

            DontDestroyOnLoad(this);
        }
        else
        {
            Destroy(gameObject);
        }
    }
예제 #28
0
    // Use this for initialization
    void Start()
    {
        _completeness     = 0;
        _fullCompleteness = 100;
        _fallOffSpeed     = 30;
        _increaseSpeed    = 8;
        _player           = GameObject.Find("Player").GetComponent <Player>();

        _em = cleanParticle.emission;
        _em.rateOverTime = 0;

        gameManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager1>();
    }
예제 #29
0
파일: Player1.cs 프로젝트: Smilotte/BitDash
 // Start is called before the first frame update
 void Start()
 {
     //load game manager
     gameManager = GameObject.Find("Pixel UI Canvas").GetComponent <GameManager1>();
     //load animator
     animator = GetComponent <Animator>();
     //load rigidbody
     rigidBody = GetComponent <Rigidbody2D>();
     //load body size
     bodySize = GetComponent <BoxCollider2D>().size;
     //load body center
     bodyCenter = GetComponent <BoxCollider2D>().offset;
 }
예제 #30
0
 // Update is called once per frame
 void Update()
 {
     SpawnPos = new Vector3(this.transform.position.x + (Random.Range(-30, 30)), this.transform.position.y, this.transform.position.z);
     if (EnLeftToKill <= 0)
     {
         if (EnLeft < 0)
         {
             EnLeft = 0;
             GameManager1 gm1 = GameObject.Find("GameManager").GetComponent <GameManager1> ();
             gm1.EnemiesLeft = EnLeft;
         }
         StartCoroutine(EndL());
     }
 }
예제 #31
0
 // Use this for initialization
 void Start()
 {
     if(autoSetup == true){
         gameManager = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameManager1>();
         playerCtrlSetup = GameObject.FindGameObjectWithTag("GameController").GetComponent<PlayerCtrlSetup>();
     }
 }