Exemplo n.º 1
0
    public void useSkill()
    {
        Debug.Log("UseSkill");
        if (IsSkillReady == true)
        {
            switch (CurrSkill)
            {
            case Skill.Shoter:
                Etcj.tmSpeed *= 1.5f;
                Damage       *= 2;
                Trail [0].gameObject.SetActive(true);
                Trail [1].gameObject.SetActive(true);
                Invoke("SkillComplete", 8.0f);
                SkillInColdTime();
                break;

            case Skill.Medical:
                GameObject box = PhotonNetwork.Instantiate(MedicalBox.name, ShotPoint.position, ShotPoint.rotation, 0, null) as GameObject;
                box.GetComponent <Rigidbody> ().AddForce(transform.TransformDirection(new Vector3(0, 0, 1) * 500));
                SkillInColdTime();
                break;

            case Skill.Tanker:
                Amw.animator.SetInteger("WeaponType_int", 8);
                Pv.RPC("changeweapon", PhotonTargets.All, null);
                shotMode = ShotMode.TankerSkill;
                SkillInColdTime();
                break;
            }
        }
        else
        {
            return;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Performs initialization of Game object.
    /// </summary>
    public void Initialize(GameMode gameMode)
    {
        this.gameMode = gameMode;
        this.state    = new NoState(this);
        gc            = GameObject.Find(GameController.NAME).GetComponent <GameController>();

        // Initialize fields
        this.holeBag           = new HoleBag(gameMode);
        this.itemBag           = new ItemBag("good");
        this.badItemBag        = new ItemBag("bad");
        this.playerAttributes  = new PlayerAttributes();
        this.terrainAttributes = new TerrainAttributes();

        inputController = new InputController(this);
        target          = Target.BALL;

        wind            = new Wind(this);
        ball            = new Ball(this);
        cursor          = new Cursor(this);
        currentDistance = new CurrentDistance(this);
        bag             = new Bag(this);
        powerbar        = new Powerbar(this);
        shotMode        = new ShotMode(this);
        score           = new Score(this);

        // Send Game reference to other objects
        GodOfUI ui = GameObject.Find(GodOfUI.NAME).GetComponent <GodOfUI>();

        ui.gameRef = this;
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Z))
        {
            Mode = ShotMode.ForceShot;
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            Mode = ShotMode.AccelerationShot;
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            Mode = ShotMode.ImpulseShot;
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            Mode = ShotMode.VelocityChangeShot;
        }

        if (Input.GetKeyDown(KeyCode.KeypadEnter))
        {
            Mode = ShotMode.BottomShot;
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            GravityMode = !GravityMode;
        }
        PointA.transform.Rotate(0, 1, 0);
    }
Exemplo n.º 4
0
    void shot()
    {
        if (CurrentShellCount <= 0)
        {
            NoAmmo = true;
            CancelInvoke("shot");
            Amw.StopFire();
            return;
        }

        Amw.Fire();
        CurrentShellCount--;
        switch (shotMode)
        {
        case ShotMode.Normal:
            GameObject CurrShell = PhotonNetwork.Instantiate(Shell.name, ShotPoint.position, ShotPoint.rotation, 0, null) as GameObject;
            CurrShell.GetComponent <Shell> ().InitShell(Pv.viewID, Damage);
            CurrShell.GetComponent <Rigidbody> ().AddForce(transform.TransformDirection(new Vector3(0, Random.Range(-Range, Range) / 100.0f, 1) * Power));
            Pv.RPC("ShotSound", PhotonTargets.All, null);
            break;

        case ShotMode.TankerSkill:
            Pv.RPC("RPGSound", PhotonTargets.All, null);
            GameObject Tankershell = PhotonNetwork.Instantiate(TankerSkillShell.name, ShotPoint.position, ShotPoint.rotation, 0, null) as GameObject;
            Tankershell.GetComponent <Shell> ().InitShell(Pv.viewID, Damage * 8);
            Tankershell.GetComponent <Rigidbody> ().AddForce(ShotPoint.transform.TransformDirection(new Vector3(0, 0, 1) * Power * 3));
            Amw.animator.SetInteger("WeaponType_int", 1);
            Pv.RPC("changeweapon", PhotonTargets.All, null);
            shotMode = ShotMode.Normal;
            break;
        }
    }
Exemplo n.º 5
0
    public override void OnActive()
    {
        trans_b_camTex.GetComponent <RawImage>().texture = CameraManager.Instan().CameraOpen(1920, 1080, 60);
        //获取UserModel的数据
        ShotMode mode = UserModel.Ins.GetShotMode();

        SetTipWithMode(mode);
        base.OnActive();
    }
Exemplo n.º 6
0
        public BaseWeapon(int refire, double energy, WeaponPoint[] p, ShotMode m)
        {
            ReloadState = 0;
            NextShot    = 0;
            EnergyCost  = energy;

            RefireRate = refire;
            Points     = p;
            Mode       = m;
        }
        /*
         *  Handler for watchButton
         */

        private void watchButton_Click(object sender, EventArgs e)
        {
            _selection.cancelClicked = false;
            ShotMode mode = ShotMode.Normal;

            if (salvoShootRadBtn.Checked)
            {
                mode = ShotMode.Salvo;
            }
            _selection.watchGame = true;
            _selection.shotMode  = mode;
            Close();
        }
Exemplo n.º 8
0
    /*
     * public void Shoot()
     * {
     *  EmmisionMode Emmision = Weapon.Emmision;
     *  ShotMode Shooting = Weapon.Shooting;
     *  ParticleMode Particles = Weapon.Particles;
     *  SoundMode Sound = Weapon.Sound;
     *
     *  if (Particles != null)
     *  {
     *      Vector3 ParticleColor = new Vector3(Particles.Coloring.r, Particles.Coloring.g, Particles.Coloring.b);
     *      PhotonNetwork.RPC(this.photonView, "PlayParticles", RpcTarget.AllBuffered, false, ParticleColor, Particles.Prefab, Particles.Type, Particles.Position);
     *  }
     *
     *  if (Sound != null && Time.time > NextTimeToPlaySound)
     *  {
     *      AudioSource Source = this.GetComponent<AudioSource>();
     *      Source.clip = Sound.Clip;
     *      Source.volume = Sound.Volume;
     *      Source.Play();
     *      NextTimeToPlaySound = Time.time + Sound.Refresh;
     *  }
     *
     *  for (int i = 0; i < Shooting.ShotCount; i++)
     *  {
     *      EmmisionType EmitType = Emmision.Type;
     *      RaycastHit Hit;
     *
     *      switch (EmitType)
     *      {
     *          case EmmisionType.Line:
     *              if (Physics.Raycast(this.transform.position, this.transform.forward, out Hit, Shooting.Range, ~(1 << LayerMask.NameToLayer("Pieces"))))
     *              {
     *                  Damage(Hit);
     *              }
     *              break;
     *          case EmmisionType.Tube:
     *              if (Physics.SphereCast(this.transform.position, Emmision.EmmisionSize, this.transform.forward, out Hit, Shooting.Range, ~(1 << LayerMask.NameToLayer("Pieces"))))
     *              {
     *                  Damage(Hit);
     *              }
     *              break;
     *      }
     *  }
     *
     *  NextTimeToFire = Time.time + (1 / Shooting.FireRate) + Shooting.Recharge;
     * }
     */

    public void Damage(GameObject Hit, Vector3 point, ShotMode Shooting, int Index, GameObject killer)
    {
        if (Hit.transform.GetComponent <Rigidbody>() != null)
        {
            Hit.transform.GetComponent <Rigidbody>().AddForce(point * Shooting.Force, ForceMode.Force);
        }

        if (Hit.transform.GetComponent <DestroyableObject>() != null)
        {
            Hit.transform.GetComponent <DestroyableObject>().GetHit(point, killer);
            //Hit.transform.GetComponent<DestroyableObject>().TakeDamage(Shooting.Damage, Hit.point, this.gameObject);
        }
    }
Exemplo n.º 9
0
 private void SetTipWithMode(ShotMode mode)
 {
     trans_b_tip.gameObject.SetActive(true);
     if (mode == ShotMode.Gif)
     {
         trans_b_hint_gif.gameObject.SetActive(true);
         trans_b_hint_photo.gameObject.SetActive(false);
     }
     else
     {
         trans_b_hint_gif.gameObject.SetActive(false);
         trans_b_hint_photo.gameObject.SetActive(true);
     }
 }
Exemplo n.º 10
0
 void Update()
 {
     if (gameEnd)
     {
         return;
     }
     if (Input.GetKey(KeyCode.Mouse0))
     {
         shotTo   = ToolBox.Instance.ScrrenToGroundPoint(0.2f);
         shotMode = ShotMode.SHOTTO;
     }
     else if (Input.GetKeyUp(KeyCode.Mouse0))
     {
         shotTo   = sourceVec3;
         shotMode = ShotMode.AUTOSHOT;
     }
 }
Exemplo n.º 11
0
 private void CheckModeAndUpdateTex()
 {
     shotMode = UserModel.Ins.GetShotMode();
     if (shotMode == ShotMode.Gif)
     {
         trans_c_GifSwitch.gameObject.SetActive(true);
         preTex = UserModel.Ins.GetPreGifTex();
         //查找gif相框
         if (gifTexRaw == null)
         {
             gifTexRaw = new RawImage[3];
         }
         if (gifRT == null)
         {
             gifRT = new RenderTexture[3];
         }
         for (int i = 1; i <= 3; i++)
         {
             gifTexRaw[i - 1]         = GameObject.Find("c_TexRaw" + i.ToString()).GetComponent <RawImage>();
             gifTexRaw[i - 1].texture = preTex[i - 1];
             gifRT[i - 1]             = GameObject.Find("c_TexCamera" + i.ToString()).GetComponent <Camera>().targetTexture;
         }
         //查找rendertexture
         trans_c_TexRaw.GetComponent <RawImage>().texture = gifRT[0];
         trans_c_btn_gl.gameObject.SetActive(false);
         gifIndex = 0;
     }
     else
     {
         if (gifTexRaw == null)
         {
             gifTexRaw = new RawImage[3];
         }
         if (gifRT == null)
         {
             gifRT = new RenderTexture[3];
         }
         gifTexRaw[0]         = GameObject.Find("c_TexRaw1").GetComponent <RawImage>();
         gifRT[0]             = GameObject.Find("c_TexCamera1").GetComponent <Camera>().targetTexture;
         gifTexRaw[0].texture = UserModel.Ins.GainCamRaw();
         trans_c_TexRaw.GetComponent <RawImage>().texture = gifRT[0];
         trans_c_GifSwitch.gameObject.SetActive(false);
     }
 }
Exemplo n.º 12
0
    private void FixedUpdate()
    {
        switch (Mode)
        {
        case ShotMode.ForceShot:
        {
            Rigidbody rb = Shot();
            rb.AddForce(PointA.transform.forward * 100, ForceMode.Force);
        }
        break;

        case ShotMode.AccelerationShot:
        {
            Rigidbody rb = Shot();
            rb.AddForce(PointA.transform.forward * 100, ForceMode.Acceleration);
        }
        break;

        case ShotMode.ImpulseShot:
        {
            Rigidbody rb = Shot();
            rb.AddForce(PointA.transform.forward * 5, ForceMode.Impulse);
        }
        break;

        case ShotMode.VelocityChangeShot:
        {
            Rigidbody rb = Shot();
            rb.AddForce(PointA.transform.forward * 5, ForceMode.VelocityChange);
        }
        break;

        case ShotMode.BottomShot:
        {
            Rigidbody rb = BtShot();
            rb.AddForce(PointB.transform.forward * 5, ForceMode.VelocityChange);
        }
        break;
        }
        if (Mode != ShotMode.None)
        {
            Mode = ShotMode.None;
        }
    }
Exemplo n.º 13
0
    void Start()
    {
        utils = Utils.GetInstance();
        // 子弹速度E:\code\unity\td_demo\Assets\Scripts\Enemy.cs
        // m_RepeatTimeItem = Timer.Instance.Post2Really(OnTimeTick, shotRate, -1);
        // 怪物速度
        // enemy_TimeItem = Timer.Instance.Post2Really(GenEnemy, 1.1f, -1);
        shotMode = ShotMode.AUTOSHOT;
        shotTo   = sourceVec3;
        // bp = new SimpleObjectPool<Bullet>(() => {
        //     var bullet = Instantiate(bulletModel);
        //     bullet.gameObject.SetActive(false);
        //     return bullet;
        // }, (Bullet bullet) => {
        //     bullet.gameObject.SetActive(false);
        //     var tr = bullet.gameObject.GetComponent<TrailRenderer>() as TrailRenderer;
        //     tr.Clear();
        //     bullet.rb.Sleep();
        // }, 50);

        // 初始化发射
    }
Exemplo n.º 14
0
        public void SwitchMode(ShotMode newMode)
        {
            if (mode == newMode)
            {
                return;
            }

            mode = newMode;
            LayerMask mask;

            if (newMode == ShotMode.Door || newMode == ShotMode.Window)
            {
                mask = 1 << (int)LayerEnums.Wall;
            }
            else
            {
                mask = 1 << (int)LayerEnums.SpatialUnderstanding;
            }
            GUIRoot.Instance.ChangeSelectedMode(mode);
            _shooter.ChangeLayer(mask.value);
            GetComponent <TextToSpeech>().StartSpeaking(mode.ToString() + " shot activated");
        }
Exemplo n.º 15
0
        /*
         *  Constructor - Accepts the game & shooting mode
         */

        public Game(bool watchGame, ShotMode mode)
        {
            _isSetupMode        = (!watchGame) ? true : false;
            _isWatchGame        = watchGame;
            _directionSettingUp = Direction.North;
            _numShotsRemaining  = 0;
            _player1            = new Player();
            _player2            = new Player(_player1);
            _player1.SetOpponent(_player2);
            _shipSettingUp = ShipType.Aircraft_Carrier;
            _shotMode      = mode;

            // Player 2 sets up its board with ships
            _player2.SetupBoard();

            if (watchGame)
            {
                // To ensure pseudorandomness
                Thread.Sleep(1500);

                // Player 1 sets up its board with ships
                _player1.SetupBoard();
            }
        }
Exemplo n.º 16
0
        public void setShotMode(ShotMode newShotMode)
        {
            this.shotMode = newShotMode;
            System.Xml.XmlNode node = this.configXmlFile.SelectSingleNode(shotmodelabel);
            if (node == null)
            {
                throw new System.Exception("the Configure file is illegal!");
            }
            System.Xml.XmlElement element = (System.Xml.XmlElement)node;

            if (newShotMode == easyShot.ShotMode.ShotSquare)
            {
                element.SetAttribute("content", ConfigManager.shotsquare);
            }
            else if (newShotMode == easyShot.ShotMode.ShotWindow)
            {
                element.SetAttribute("content", ConfigManager.shotwindow);
            }
            else
            {
                element.SetAttribute("content", ConfigManager.shotsquare);
            }
            configXmlFile.Save(configXmlFilePath);
        }
Exemplo n.º 17
0
 public void ChangeSelectedMode(ShotMode mode)
 {
     selectedMode.sprite = Resources.Load <Sprite>("Icons/" + mode.ToString());
 }
Exemplo n.º 18
0
 /// <summary>
 /// 攻撃関連のコンフィグ設定
 /// </summary>
 public void SetAttackConfig(ShotMode shotMode, ReloadMode reloadMode)
 {
     this.shotMode   = shotMode;
     this.reloadMode = reloadMode;
 }
Exemplo n.º 19
0
    public void Shoot(FiringPoint Point, int Index)
    {
        EmmisionMode Emmision  = Point.Emmision;
        ShotMode     Shooting  = Point.Shooting;
        ParticleMode Particles = Point.Particles;
        SoundMode    Sound     = Point.Sound;

        Vector3 ShootPosition = this.transform.position + this.transform.TransformDirection(Vector3.forward);

        switch (Emmision.Positioning)
        {
        case ShotPositioning.Direct:
            ShootPosition = this.transform.position + this.transform.forward;
            break;

        case ShotPositioning.Weapon1:
            ShootPosition = Weapons.ElementAt(0).position + this.transform.forward;
            break;

        case ShotPositioning.Weapon2:
            ShootPosition = Weapons.ElementAt(1).position + this.transform.forward;
            break;

        case ShotPositioning.Split:
            int CurrentWeapon = SplitFiringSelection.ElementAt(Index);
            ShootPosition = Weapons.ElementAt(CurrentWeapon).position + this.transform.forward;
            switch (CurrentWeapon)
            {
            case 0:
                SplitFiringSelection[Index] = 1;
                break;

            case 1:
                SplitFiringSelection[Index] = 0;
                break;
            }
            break;
        }
        if (Emmision.EmmisionRandomOffset != Vector3.zero && Emmision.EmmisionRandomOffset != null)
        {
            ShootPosition.x += Random.Range(-Emmision.EmmisionRandomOffset.x, Emmision.EmmisionRandomOffset.x);
            ShootPosition.y += Random.Range(-Emmision.EmmisionRandomOffset.y, Emmision.EmmisionRandomOffset.y);
            ShootPosition.z += Random.Range(-Emmision.EmmisionRandomOffset.z, Emmision.EmmisionRandomOffset.x);
        }

        Vector3    ParticlesPosition = Emmision.EmmisionOffset + Particles.Position;
        Quaternion ShootRotation     = this.transform.rotation * Quaternion.Euler(Emmision.RotationOffset);

        if (Particles.HasParticles == true)
        {
            Vector3 ParticleColor = new Vector3(Particles.Coloring.r, Particles.Coloring.g, Particles.Coloring.b);
            PhotonNetwork.RPC(this.photonView, "PlayParticles", RpcTarget.AllBuffered, false, ParticleColor,
                              Particles.Prefab, Particles.Type, ParticlesPosition, ShootRotation, Index, Particles.Size);
        }


        if (Sound != null && Time.time > NextTimeToPlaySound)
        {
            AudioSource Source = this.GetComponent <AudioSource>();
            Source.PlayOneShot(Sound.Clip, Sound.Volume);
            NextTimeToPlaySound = Time.time + Sound.Refresh;
        }

        for (int i = 0; i < Shooting.ShotCount; i++)
        {
            /*
             * EmmisionType EmitType = Emmision.Type;
             * RaycastHit Hit;
             * var dir = Quaternion.Euler(Emmision.RotationOffset) * this.transform.forward;
             * Debug.DrawRay(ShootPosition, dir, Color.cyan);
             *
             * switch (EmitType)
             * {
             *  case EmmisionType.Line:
             *      if (Physics.Raycast(ShootPosition, dir, out Hit, Shooting.Range, ~(1 << LayerMask.NameToLayer("Pieces"))))
             *      {
             *          Damage(Hit, Shooting, Index);
             *      }
             *      break;
             *  case EmmisionType.Tube:
             *      if (Physics.SphereCast(ShootPosition, Emmision.EmmisionSize, dir, out Hit, Shooting.Range, ~(1 << LayerMask.NameToLayer("Pieces"))))
             *      {
             *          Damage(Hit, Shooting, Index);
             *      }
             *
             * break;
             * }
             */

            //Quaternion dir = Quaternion.Euler(Quaternion.Euler(Emmision.RotationOffset) * this.transform.forward);
            Quaternion dir        = this.transform.rotation * Quaternion.Euler(Emmision.RotationOffset);
            GameObject projectile = PhotonNetwork.Instantiate(Emmision.Prefab, ShootPosition, dir);
            projectile.layer = LayerMask.NameToLayer("Bullets");
            projectile.transform.SetParent(GameObject.Find("TempStorage").transform);
            projectile.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;
            PhotonNetwork.RPC(photonView, "SetProjectile", RpcTarget.AllBuffered, false, projectile.gameObject.GetPhotonView().ViewID,
                              this.gameObject.GetPhotonView().ViewID, new Vector3(Particles.ProjectileColor.r, Particles.ProjectileColor.g, Particles.ProjectileColor.b));
            projectile.GetComponent <Renderer>().sharedMaterial.color = Particles.ProjectileColor;

            Bullet b = projectile.AddComponent <Bullet>();
            b.shooter  = this.transform;
            b.Shooting = Shooting;
            b.index    = Index;
            b.speed    = Shooting.Speed;
            b.maxRange = Shooting.Range;
            b.force    = Shooting.Force;
            b.Fire();
        }

        NextTimesToFire[Index] = Time.time + (1 / Shooting.FireRate) + Shooting.Recharge;
        if (NextTimesToFire[Index] == Mathf.Infinity || NextTimesToFire[Index] == Mathf.NegativeInfinity)
        {
            NextTimesToFire[Index] = 0;
        }
    }
Exemplo n.º 20
0
 private UserModel(ShotMode _shotMode)
 {
     shotMode = _shotMode;
 }
Exemplo n.º 21
0
 /// <summary>
 /// 设置拍摄模式
 /// </summary>
 /// <param name="mode"></param>
 public void SetShotMode(ShotMode mode)
 {
     shotMode = mode;
 }