Пример #1
0
    // Update is called once per frame
    void Update()
    {
        gamemanagerscript = GameObject.FindObjectOfType <gamemanager> ();

        if (!gamemanagerscript.playerdeath)
        {
            playerposition = GameObject.FindObjectOfType <characterscript> ().GetComponent <characterscript> ().transform.position;
            difference     = transform.position - playerposition;

            if (difference.x <= 16f && difference.x >= 2f)
            {
                shooting = true;
            }
            else
            {
                shooting = false;
            }

            difference.Normalize();
            float rotz = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;              // find the angles in degrees


            if (Time.time > cooldowntimer && shooting)
            {
                cooldowntimer = Time.time + firedelay;
                gunanim.SetTrigger("tankshoot");
                GameObject bulletinstance;
                bulletinstance = Instantiate(tankbullet, firepoint.position, transform.rotation) as GameObject;
                bulletinstance.GetComponent <Rigidbody2D> ().AddForce(Vector3.left * 1000f);
            }
        }
    }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     spawnlocobj = GameObject.FindGameObjectWithTag("spawnloc");
     gamemangerref = GetComponent<gamemanager>();
     StartCoroutine(levelstart());
     faceamount = faceobjs.Length;
 }
Пример #3
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        gamemanagerscript = GameObject.FindObjectOfType <gamemanager> ();

        playertransform = GameObject.FindObjectOfType <characterscript> ().transform;

        if ((transform.position - playertransform.position).x <= 23f && (transform.position - playertransform.position).x >= 6f)
        {
            shoot = true;
        }
        else if (shoot && rot)
        {
            shoot = false;
            rot   = false;
        }


        if (rot && shoot)
        {
            difference = transform.position - playertransform.position;
            difference.Normalize();
            float rotz = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;              // find the angles in degrees
            transform.rotation = Quaternion.Euler(0f, 0f, rotz);
        }


        if (shoot && !gamemanagerscript.playerdeath && Time.time > cooldowntimer)
        {
            GameObject.FindObjectOfType <camerashake> ().GetComponent <camerashake> ().Shake(0.03f, 0.05f);
            cooldowntimer = Time.time + 1f;
            StartCoroutine(shootconsecutive());
            //anim.SetTrigger ("shoot");
        }
    }
Пример #5
0
 // Use this for initialization
 void Start()
 {
     gameManager        = GameObject.Find("Game Manager").GetComponent <gamemanager>();
     inputScript        = GameObject.Find("Player/CardboardMain").GetComponent <inputScript>();
     wastedSign         = GameObject.Find("Player/CardboardMain/Head/wasted").GetComponent <Renderer>();
     wastedSign.enabled = false;
 }
Пример #6
0
 private void Awake()
 {
     Instance = this;
     // Add function NpcOnMouseUp to NPC MouseUP event
     _npc.MouseUp += NpcOnMouseUp;
     chatCanvas.gameObject.SetActive(false);
 }
Пример #7
0
 // Start is called before the first frame update
 void Start()
 {
     DontDestroyOnLoad(this);
     instanc       = this;
     time          = 0;
     playerControl = itemBag.GetComponent <PlayerControl>();
 }
Пример #8
0
    public string must_color, temp_color;                              //手牌中有就一定要打出的花色、暫存用的花色變數


    void Awake()
    {
        if (manager == null)
        {
            manager = this;
        }
    }
Пример #9
0
 // Start is called before the first frame update
 void Start()
 {
     isNear = false;
     pu     = player.GetComponent <playerUI>();
     gm     = FindObjectOfType <gamemanager>();
     //animator = transform.parent.GetComponent<Animator>();
 }
Пример #10
0
 // Start is called before the first frame update
 void Start()
 {
     deathcounter = 0;
     gamemanag    = GameObject.Find("background").GetComponent <gamemanager>();
     direccionx   = new Vector3(1, 0, 0);
     direcciony   = new Vector3(0, -0.5f, 0);
 }
Пример #11
0
 // Use this for initialization
 void Start()
 {
     gameManager = GameObject.Find ("Game Manager").GetComponent<gamemanager>();
     inputScript = GameObject.Find("Player/CardboardMain").GetComponent<inputScript>();
     wastedSign = GameObject.Find("Player/CardboardMain/Head/wasted").GetComponent<Renderer>();
     wastedSign.enabled = false;
 }
Пример #12
0
 // Use this for initialization
 void Start()
 {
     Gamemanager             = GameObject.Find("Gamemanager").GetComponent <gamemanager>();
     startPoint              = GameObject.Find("playerStartPoint").GetComponent <Transform>();
     this.transform.position = startPoint.position;
     rigidbody = GetComponent <Rigidbody2D>();
 }
Пример #13
0
    private int totalNum = 30;          //全部的关卡数量

    private void Awake()
    {
        instance = this;
        if (birds.Count > 0)
        {
            origion = birds[0].transform.position; //第一只小鸟的位置
        }
    }
Пример #14
0
    // string[] names = Input.GetJoystickNames();

    void Awake()
    {
        //Random.InitState(System.DateTime.Now.Second * System.DateTime.Now.Minute);
        if (Instance == null)
        {
            Instance = this;
        }
        audioSource = GetComponent <AudioSource>();
    }
Пример #15
0
    public static void savedata(gamemanager gm)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.fun";
        FileStream      stream    = new FileStream(path, FileMode.Create);
        playerdata      data      = new playerdata(gm);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Пример #16
0
 // Start is called before the first frame update
 void Start()
 {
     player           = GameObject.FindGameObjectWithTag("Player");
     aIEnemyControl   = GetComponent <AIEnemyControl>();
     thirdPersonEnemy = GetComponent <ThirdPersonEnemy>();
     m_Animator       = GetComponent <Animator>();
     attackSFX        = this.GetComponent <AudioSource>();
     projectileToUse.SetActive(true);
     tp = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
     gm = GameObject.FindGameObjectWithTag("gamemanager").GetComponent <gamemanager>();
 }
Пример #17
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Bullet")
        {
            gamemanag = GameObject.Find("background").GetComponent <gamemanager>();
            gamemanag.Puntuar(points);
            gamemanag.CountEnemies();


            Destroy(gameObject);
        }
    }
Пример #18
0
    void Start()
    {
        //  :)
        playerScript = GameObject.Find("Player").GetComponent <PlayerBlob>();
        dialogues    = GameObject.FindGameObjectsWithTag("Dialogue");

        if (Instance)
        {
            Destroy(Instance);
        }
        Instance = this;
    }
Пример #19
0
    void ApplySingleton()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }
    }
Пример #20
0
 void Awake()
 {
     stop = false;
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
     DontDestroyOnLoad(this.gameObject);
 }
Пример #21
0
    // Start is called before the first frame update
    void Start()
    {
        score.text = "Score: " + 27;
        gameover.gameObject.SetActive(false);
        returnkey.gameObject.SetActive(false);
        exitbutton.gameObject.SetActive(false);
        gm = GameObject.Find("gamemanager").GetComponent <gamemanager>();

        if (gm == null)
        {
            Debug.Log("game manager not loaded");
        }
    }
Пример #22
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
         return;
     }
     DontDestroyOnLoad(gameObject);
 }
Пример #23
0
 // Use this for initialization
 void Start()
 {
     lowPassFilterFactor = accelerometerUpdateInterval / lowPassKernelWidthInSeconds;
     shakeDetectionThreshold *= shakeDetectionThreshold;
     //Debug.Log("skakeThresh = " + shakeDetectionThreshold);
     lowPassValue = Input.acceleration;
     headbuttZone = GameObject.Find("Player/headbutt zone");
     player = GameObject.Find("Player");
     headbuttZone.SetActive(false);
     stepSound = GameObject.Find("Player/step sound").GetComponent<AudioSource>();
     whooshSound = GameObject.Find("Player/whoosh sound").GetComponent<AudioSource>();
     gameManager = GameObject.Find ("Game Manager").GetComponent<gamemanager>();
 }
Пример #24
0
 // Use this for initialization
 void Start()
 {
     lowPassFilterFactor      = accelerometerUpdateInterval / lowPassKernelWidthInSeconds;
     shakeDetectionThreshold *= shakeDetectionThreshold;
     //Debug.Log("skakeThresh = " + shakeDetectionThreshold);
     lowPassValue = Input.acceleration;
     headbuttZone = GameObject.Find("Player/headbutt zone");
     player       = GameObject.Find("Player");
     headbuttZone.SetActive(false);
     stepSound   = GameObject.Find("Player/step sound").GetComponent <AudioSource>();
     whooshSound = GameObject.Find("Player/whoosh sound").GetComponent <AudioSource>();
     gameManager = GameObject.Find("Game Manager").GetComponent <gamemanager>();
 }
Пример #25
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);

        Assert.IsNotNull(mainMenu);
    }
Пример #26
0
 private void Awake()
 {
     if (instance == null)
     {
         Debug.Log("Creating a new version of GameManager.");
         instance = this;
     }
     else if (instance != this)
     {
         Debug.Log("GameManager already exists.");
         Destroy(this.gameObject);
         return;
     }
 }
Пример #27
0
    void Start()
    {
        canSpeak = false;
        gamey    = GameObject.Find("GameMNGR").GetComponent <gamemanager>();

        for (int i = 0; i < gamey.dialogues.Length; i++)
        {
            gamey.dialogues[i].SetActive(false);
        }

        //foreach (GameObject go in dialogues)
        //{
        //    go.SetActive(false);
        //}
    }
Пример #28
0
    // Update is called once per frame
    void Update()
    {
        gamemangerscript = GameObject.FindObjectOfType <gamemanager> ();

        if (health <= 0)
        {
            Instantiate(bodyparts, transform.position, transform.rotation);
            Destroy(gameObject);
        }


        if (!gamemangerscript.playerdeath)
        {
            body2d.velocity = new Vector2(speed, body2d.velocity.y);
        }
    }
Пример #29
0
    // Use this for initialization
    void Awake()
    {
        if (instance == null)
        {
            //if not, set instance to this
            instance = this;
        }

        //If instance already exists and it's not this:
        else if (instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }

        //Sets this to not be destroyed when reloading scene
        DontDestroyOnLoad(gameObject);
    }
Пример #30
0
    //must be set before other things
    void Awake()
    {
        instance = this;

        if (makeGrid)
        {
            MakeGrid();
        }

        //set current player position
        playerPos = Get2DPos(player.transform.position);

        //create board
        board = new slot[gridSize.x, gridSize.y];

        //fill board
        GridSetter2();
    }
Пример #31
0
    // float timer;
    // float timelimit = 5f;
    // bool timerend = true;


    public void Start()
    {
        Instance = this;
        client   = FindObjectOfType <Client>();

        BulletAdefended = GameObject.Find("bulletofAdefended").GetComponent <Animator>();
        BulletAattacked = GameObject.Find("bulletofAattacked").GetComponent <Animator>();
        BulletBdefended = GameObject.Find("bulletofBdefended").GetComponent <Animator>();
        BulletBattacked = GameObject.Find("bulletofBattacked").GetComponent <Animator>();
        anim            = GameObject.Find("roudnfadeanim").GetComponent <Animator>();

        round = 1;
        As    = client.initialscore;
        Bs    = client.initialscore;

        Roundcounter.text = round.ToString();
        scoreofA.text     = As.ToString();
        scoreofB.text     = Bs.ToString();

        if (client.isHost)
        {
            clientwho           = "A";
            clientAname.text    = client.clientName;
            clientBname.text    = client.otherclientName;
            clientAnamemsg.text = client.clientName;
            clientBnamemsg.text = client.otherclientName;
            inputmessageofA.SetActive(true);
            inputmessageofB.SetActive(false);
        }
        else
        {
            clientwho           = "B";
            clientAname.text    = client.otherclientName;
            clientBname.text    = client.clientName;
            clientAnamemsg.text = client.otherclientName;
            clientBnamemsg.text = client.clientName;
            inputmessageofA.SetActive(false);
            inputmessageofB.SetActive(true);
        }

        Restictotherclients(clientwho);
        inputdone = false;
    }
Пример #32
0
    // =================================
    void Start()
    {
        numberBytes = 1464;
        print("UDPmanager start...");
        // =================
        gameman = GameObject.Find("GameManager");
        gm      = gameman.GetComponent <gamemanager>();
        // =================
        Application.runInBackground = true;
        // set up socket
        sckCommunication = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
        sckCommunication.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);

        txtLocalIp = gm.clientIp;
        txtLocalIp = GetLocalIP();

        txtServerIp = gm.serverIp;

        txtLocalPort = gm.clientPort;

        txtServerPort = gm.serverPort;

        txtLocalPort = new System.Random().Next(50000, 51000);

        txtgui = "port=" + txtLocalPort + ',' + txtLocalIp;
        // bind socket
        epLocal = new IPEndPoint(IPAddress.Parse(txtLocalIp), txtLocalPort);
        sckCommunication.Bind(epLocal);

        // connect to remote ip and port
        epRemote = new IPEndPoint(IPAddress.Parse(txtServerIp), txtServerPort);
        sckCommunication.Connect(epRemote);

        // starts to listen to an specific port
        print("UDPmanager listening on port " + gm.clientPort);

        //buffer = new byte[numberBytes];
        buffer = new byte[numberBytes];


        sckCommunication.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None,
                                          ref epRemote, new AsyncCallback(OperatorCallBack), buffer);
    }
Пример #33
0
    // Update is called once per frame
    void Update()
    {
        gamemangerscript = GameObject.FindObjectOfType <gamemanager> ();

        if (health <= 0)
        {
            Instantiate(bodyparts, transform.position, transform.rotation);
            Destroy(gameObject);
        }

        if (walking == false)
        {
            anim.SetBool("shoot", true);
            speed = 0f;
        }

        if (!gamemangerscript.playerdeath)
        {
            body2d.velocity = new Vector2(speed, body2d.velocity.y);
        }
    }
Пример #34
0
 // Use this for initialization
 void Start()
 {
     audio = GetComponent<AudioSource>();
     gameManager = GameObject.Find ("Game Manager").GetComponent<gamemanager>();
 }
Пример #35
0
 // Use this for initialization
 void Start()
 {
     myAudio = GetComponent<AudioSource>();
     myParticles = transform.Find("Particle System").GetComponent<ParticleSystem>();
     gameManager = GameObject.Find ("Game Manager").GetComponent<gamemanager>();
 }
Пример #36
0
 //
 private void Awake()
 {
     faceobj = transform.GetChild(0).gameObject;
     backfaceobj = faceobj.transform.GetChild(0).gameObject;
     endingloc = new Vector3 (Random.Range(xnegarealimit,xposarealimit),transform.position.y,Random.Range(znegarealimit,transform.position.z));
     randomwaittime = Random.Range(waitrange1,waitrange2);
     intstate =1;
     //test code
     gamemanagerref =  GameObject.FindGameObjectWithTag("GameController").GetComponent<gamemanager>();
     //test code
     playertrans = GameObject.FindGameObjectWithTag("Player").transform;
     enemystatsref = GetComponent<enemystats>();
     enemystrength = enemystatsref.enemynegstrength;
 }