Пример #1
0
        void GenerateRandomBlackHole()
        {
            Vector2    point = Vector2Extension.RandomPosition();
            GameObject obj   = PhotonNetwork.Instantiate("BlackHole", point, Quaternion.identity, 0);

            DontDestroyOnLoad(obj);
        }
Пример #2
0
        void FixedUpdate()
        {
            if (photonView.isMine == false && PhotonNetwork.connected == true)
            {
                return;
            }
            Rigidbody2D rb2d     = GetComponent <Rigidbody2D> ();
            Vector2     shootVec = new Vector2(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical"));

            // Rotate
            if (shootVec.magnitude > 0)
            {
                float angle = Mathf.Atan2(shootVec.y, shootVec.x) * Mathf.Rad2Deg - 90f;
                rb2d.rotation = angle;
                this.GetComponent <Rigidbody2D> ().angularDrag = 5;
            }
            else
            {
                this.GetComponent <Rigidbody2D> ().angularDrag = 0;
            }
            if (IsFiring && LocalPlayerInstance.Equals(Constant.StoneElementType))
            {
                return;                 // Stone in charging state will not move
            }

            // Moving
            Vector2 moveVec = new Vector2(CrossPlatformInputManager.GetAxis("LeftHorizontal"), CrossPlatformInputManager.GetAxis("LeftVertical"));

            if (moveVec.magnitude > 0)
            {
                this.GetComponent <Rigidbody2D> ().drag = 20;
            }
            else
            {
                this.GetComponent <Rigidbody2D> ().drag = 0;
            }
            if (!Shrinking)
            {
                rb2d.position += moveVec.normalized * 0.05f * playerInfo.speed * 0.01f;
            }

            // Shrinking
            if (Shrinking)
            {
                transform.localScale *= 0.9f;
                if (transform.localScale.magnitude < 0.01f)
                {
                    Shrinking            = false;
                    transform.localScale = Vector3.one;
                    NextBlackHoleTime    = Time.time + 1f;
                    rb2d.position        = Vector2Extension.RandomPosition();
                }
            }
        }
Пример #3
0
        void OnTriggerEnter2D(Collider2D obj)
        {
            PhotonView pv = obj.transform.GetComponent <PhotonView> ();

            if (obj.CompareTag("Element"))
            {
                Debug.Log("Blackhole: an element hits me");
                if (photonView.isMine == true && PhotonNetwork.connected == true)
                {
                    pv.RPC("ChangeLocation", PhotonTargets.All, Vector2Extension.RandomPosition());
                }
            }
        }
Пример #4
0
 public override void fire(Vector2 position, float angle, Vector2 direction)
 {
     if (playerInfo.isUsingPowerUp)
     {
         fireOneBullet(position, angle, direction);
         fireOneBullet(position, angle + 30f, Vector2Extension.Rotate(direction, 30));
         fireOneBullet(position, angle - 30f, Vector2Extension.Rotate(direction, -30));
     }
     else
     {
         fireOneBullet(position, angle, direction);
     }
 }
Пример #5
0
        public void Start()
        {
            Instance = this;
            if (PlayerManager.LocalPlayerInstance == null)
            {
                Debug.Log("We are Instantiating LocalPlayer from " + Application.loadedLevel);
                PhotonNetwork.Instantiate(PlayerManager.LocalPlayerType, Vector2Extension.RandomPosition() * 0.5f, Quaternion.identity, 0);
//				PhotonNetwork.Instantiate (PlayerManager.LocalPlayerType, Vector3.zero, Quaternion.identity, 0);
            }
            else
            {
                Debug.Log("Ignoring scene load for " + Application.loadedLevel);
            }
        }