Exemplo n.º 1
0
    protected override void Update()
    {
        //this.lblTimeLimit.text = string.Format("残り時間::{0:f2}", this.gameTimeLimit);
        //base.Update ();
        if (!this.isPlaying)
        {
            return;
        }
        if (gameTimer >= gameSetTime)
        {
            GameOver();
        }
        if (isHit)
        {
            this.GameClear();
        }
        else if (bullet == 0)
        {
            this.GameOver();
        }

        if (isMiss && bullet > 0)
        {
            P_shot = Util.InstantiateComponent <shot>(shotprefab, this.transform);
            P_shot.transform.position = shotPosition;
            //ボタンにP_shotをアタッチしなおす
            button.target = P_shot.gameObject;
            bullet--;
            isMiss       = false;
            destroy.shot = P_shot;
        }
    }
Exemplo n.º 2
0
    public void detectDistance()
    {
        float distanceSqr = (transform.position - PJ.transform.position).sqrMagnitude;

        //En caso que el objetivo este a menos de 30 de distancia dispararan un proyectil
        if (distanceSqr < 30)
        {
            attack = true;
            if (canshot)
            {
                animator.SetBool("idle", false);
                animator.SetBool("shot", true);
                shot shot = Instantiate(shots, new Vector2(transform.localPosition.x - (movementX * 2), transform.localPosition.y), transform.rotation);
                shot.GetComponent <shot>().direction = movementX * -1;
                shot.GetComponent <shot>().alien     = this;
                canshot = false;
                startDelay();
            }
            else
            {
                animator.SetBool("idle", true);
            }
        }
        else
        {
            attack = false; animator.SetBool("shot", false);
        }
    }
Exemplo n.º 3
0
    public void CmdFire(bool fakeshot, Vector3 veloc)
    {
        nextFire = Time.time + fireRate;

        Transform case2 = this.transform.Find("FirstPersonCharacter");
        Transform case3 = case2.transform.Find("arm");
        Transform case4 = case3.transform.Find("bulletCase");

        Rigidbody bullet = Instantiate(bulletCasing, case4.position, case4.rotation);

        if (fakeshot)
        {
            bullet.velocity = veloc;
            shot b = bullet.GetComponent <shot>();
            b.playerFrom = this;
            if (fakeshot)
            {
                b.fakeshot = true;
            }
        }
        else
        {
            bullet.velocity = case4.TransformDirection(Vector3.left) * ejectSpeed;
            shotVelocity    = bullet.velocity;
            shot b = bullet.GetComponent <shot>();
            b.playerFrom = this;
            if (fakeshot)
            {
                b.fakeshot = true;
            }
        }

        Destroy(bullet, 2.0f);
    }
Exemplo n.º 4
0
        private void shoot(Vector2 target)
        {
            shot s = new shot(this.Center, false);

            s.bullet.ShouldTravel      = true;
            s.bullet.VelocityDirection = target - Center;
            list.Add(s);
        }
Exemplo n.º 5
0
 void Awake()
 {
     trackedObj = GetComponent <SteamVR_TrackedObject>();
     player     = transform.GetComponentInParent <Transform>().GetComponentInParent <shot>();
     Debug.Log("1. test" + text);
     text = transform.GetComponentInChildren <Canvas>().GetComponentInChildren <Hand_Text_maneger>();
     Debug.Log("test" + text);
     switchGun();
 }
Exemplo n.º 6
0
        public Vector2 Update(Enemy[] enemy, WallSet walls)
        {
            Vector2 s = new Vector2(-1f, -1f);

            for (int i = 0; i < list.Count; i++)
            {
                shot temp = list[i];
                if (list[i].shotLife == 0)
                {
                    list[i].bullet.RemoveFromAutoDrawSet();
                    list[i].emitter.RemoveFromAutoDrawSet();
                    list.Remove(list[i]);
                }
                else
                {
                    temp.shotLife--;
                    for (int j = 0; j < enemy.Length; j++)
                    {
                        list[i] = temp;
                        if (list[i].bullet.Collided(enemy[j]) && !list[i].hit)
                        {
                            enemy[j].Caught();
                            if (enemy[j].NumLivesLeft <= 0)
                            {
                                s = enemy[j].TurnEnemyToBunny();
                            }

                            temp.bullet.RemoveFromAutoDrawSet();
                            temp.emitter.RemoveFromAutoDrawSet();
                            list.Remove(list[i]);
                            temp.hit = true;
                            break;
                        }
                    }
                    if (!temp.hit)
                    {
                        list[i] = temp;

                        list[i].emitter.Center = list[i].bullet.Center;

                        for (int k = 0; k < walls.RoomWalls.Length; k++)
                        {
                            if (temp.bullet.Collided(walls.RoomWalls[k]))
                            {
                                temp.bullet.RemoveFromAutoDrawSet();
                                temp.emitter.RemoveFromAutoDrawSet();
                                list.Remove(list[i]);
                            }
                        }
                    }
                }
            }

            return(s);
        }
        public void Shoot(XNACS1Rectangle hero)
        {
            shot s = new shot(hero.Center, false);
            s.bullet.ShouldTravel = true;
            s.bullet.Velocity = (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0) ? new Vector2(hero.Texture == "pennyRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;
            list.Add(s);
            XNACS1Base.PlayACue("spell");

            //shot s2 = new shot(hero.Center, false);
            //s2.bullet.ShouldTravel = true;
            //s2.bullet.Velocity = s.bullet.Velocity;
            //s2.bullet.VelocityY = 0.25f;
            //list.Add(s2);
        }
Exemplo n.º 8
0
    //delete the whole plane
    public void deletePlane(int y)
    {
        for (int x = 0; x < w; ++x)
        {
            for (int z = 0; z < l; ++z)
            {
                Destroy(grid[x, y, z].gameObject);
                grid[x, y, z] = null;
            }
        }
        clearLineNum++;
        shot other = (shot)GameObject.Find("hand_right").GetComponent(typeof(shot));

        other.AddAmmo();
    }
Exemplo n.º 9
0
        public void Shoot(XNACS1Rectangle hero)
        {
            shot s = new shot(hero.Center, false);

            s.bullet.ShouldTravel = true;
            s.bullet.Velocity     = (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0) ? new Vector2(hero.Texture == "pennyRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;
            list.Add(s);
            XNACS1Base.PlayACue("spell");

            //shot s2 = new shot(hero.Center, false);
            //s2.bullet.ShouldTravel = true;
            //s2.bullet.Velocity = s.bullet.Velocity;
            //s2.bullet.VelocityY = 0.25f;
            //list.Add(s2);
        }
Exemplo n.º 10
0
        public Vector2 Update(Enemy[] enemy)
        {
            Vector2 s = new Vector2(-1f, -1f);

            for (int i = 0; i < list.Count; i++)
            {
                shot temp = list[i];
                if (list[i].shotLife == 0)
                {
                    list[i].bullet.RemoveFromAutoDrawSet();
                    list[i].emitter.RemoveFromAutoDrawSet();
                    list.Remove(list[i]);
                }
                else
                {
                    temp.shotLife--;
                    for (int j = 0; j < enemy.Length; j++)
                    {
                        list[i] = temp;
                        if (list[i].bullet.Collided(enemy[j]) && !list[i].hit)
                        {
                            s        = enemy[j].TurnEnemyToBunny();
                            temp.hit = true;
                            list[i]  = temp;
                        }
                        list[i].emitter.Center = list[i].bullet.Center;
                    }

                    BoundCollideStatus status = XNACS1Base.World.CollideWorldBound(temp.bullet);
                    switch (status)
                    {
                    case BoundCollideStatus.CollideBottom:
                    case BoundCollideStatus.CollideLeft:
                    case BoundCollideStatus.CollideRight:
                    case BoundCollideStatus.CollideTop:
                        temp.bullet.RemoveFromAutoDrawSet();
                        temp.emitter.RemoveFromAutoDrawSet();
                        list.Remove(list[i]);
                        break;
                    }
                }
            }

            return(s);
        }
Exemplo n.º 11
0
        public Vector2 Update(Enemy enemy)
        {
            Vector2 s = new Vector2(-1f, -1f);

            for (int i = 0; i < list.Count; i++)
            {
                shot temp = list[i];
                if (list[i].bullet.Collided(enemy) && !list[i].hit)
                {
                    s        = enemy.TurnEnemyToBunny();
                    temp.hit = true;
                    list[i]  = temp;
                }
                list[i].emitter.Center = list[i].bullet.Center;
            }

            return(s);
        }
        public void Shoot(XNACS1Rectangle hero)
        {
            shot s = new shot(hero.Center, false);
            s.bullet.ShouldTravel = true;
            s.bullet.Velocity = (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0) ? new Vector2(hero.Texture == "heroRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;
            list.Add(s);

            BoundCollideStatus status = XNACS1Base.World.CollideWorldBound(s.bullet);
            switch (status) {
                case BoundCollideStatus.CollideBottom:
                case BoundCollideStatus.CollideLeft:
                case BoundCollideStatus.CollideRight:
                case BoundCollideStatus.CollideTop:
                    s.bullet.RemoveFromAutoDrawSet();
                    list.Remove(s);
                    s.bullet = null;
                    break;
            }
        }
Exemplo n.º 13
0
    public void Update()
    {
        shot cure = player.GetComponent <shot> ();

        if (inTrigger)
        {
            if (Input.GetKeyDown("g") && cure.Cure > 10)
            {
                cure.Cure -= 10;
                DestroyAllObjects();
                anim.Play("wake");
                Destroy(text);
                StartCoroutine(restart());
            }
        }
        if (flag == true)
        {
            FaceTarget();
        }
    }
Exemplo n.º 14
0
        public void Shoot(XNACS1Rectangle hero)
        {
            shot s = new shot(hero.Center, false);

            s.bullet.ShouldTravel = true;
            s.bullet.Velocity     = (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0) ? new Vector2(hero.Texture == "heroRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;
            list.Add(s);

            BoundCollideStatus status = XNACS1Base.World.CollideWorldBound(s.bullet);

            switch (status)
            {
            case BoundCollideStatus.CollideBottom:
            case BoundCollideStatus.CollideLeft:
            case BoundCollideStatus.CollideRight:
            case BoundCollideStatus.CollideTop:
                s.bullet.RemoveFromAutoDrawSet();
                list.Remove(s);
                s.bullet = null;
                break;
            }
        }
Exemplo n.º 15
0
        private void button5_Click(object sender, EventArgs e)
        {
            string buttonText = button5.Text;

            if (buttonText == "打开截图框")
            {
                st         = new shot();
                st.TopMost = true;
                st.BringToFront();
                st.Show();
                button5.Text = "截取";
            }
            else if (buttonText == "截取")
            {
                st.TopMost = true;
                st.BringToFront();
                st.button1_Click(sender, e);
                button5.Text      = "打开截图框";
                pictureBox3.Image = st.pic;
                st.Close();
            }

            //  pictureBox3.Image = Image.FromFile(picFilename);
        }
Exemplo n.º 16
0
        public void Shoot(XNACS1Rectangle hero)
        {
            Vector2 velDir;
            XNACS1Base.PlayACue("spell");
            switch (level) {
                case 0:
                    shot s = new shot(hero.Center, false);
                    s.bullet.ShouldTravel = true;
                    s.bullet.VelocityDirection =
                        (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0)
                        ? new Vector2(hero.Texture == "newPrincessRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;
                    list.Add(s);
                    break;

                case 1:
                    shot s2 = new shot(hero.Center, false);
                    shot s3 = new shot(hero.Center, false);

                    velDir =
                        (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0)
                        ? new Vector2(hero.Texture == "newPrincessRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;

                    if (velDir.X < 0f && velDir.Y < 0f) {
                        s2.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                        s3.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                    }

                    else if (velDir.Y < 0f && velDir.X > 0f) {
                        s2.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y - .1f);
                        s3.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y + .1f);

                    }

                    else if (velDir.Y > 0f && velDir.X < 0f) {
                        s2.bullet.VelocityDirection = new Vector2(velDir.X -.1f , velDir.Y);
                        s3.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y);
                    }

                    else {
                        s2.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                        s3.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                    }

                    s2.bullet.ShouldTravel = true;
                    s3.bullet.ShouldTravel = true;
                    list.Add(s2);
                    list.Add(s3);

                    break;

                case 2:
                    shot s4 = new shot(hero.Center, false);
                    shot s5 = new shot(hero.Center, false);
                    shot s6 = new shot(hero.Center, false);

                    s4.bullet.ShouldTravel = true;
                    s5.bullet.ShouldTravel = true;
                    s6.bullet.ShouldTravel = true;

                    velDir =
                        (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0)
                        ? new Vector2(hero.Texture == "newPrincessRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;

                    if (velDir.X < 0f && velDir.Y < 0f) {
                        s4.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                        s5.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                        s6.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                    }

                    else if (velDir.Y < 0f && velDir.X > 0f) {
                        s4.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                        s5.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y - .1f);
                        s6.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y + .1f);

                    }

                    else if (velDir.Y > 0f && velDir.X < 0f) {
                        s4.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                        s5.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y);
                        s6.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y);
                    }

                    else {
                        s4.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                        s5.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                        s6.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                    }

                    list.Add(s4);
                    list.Add(s5);
                    list.Add(s6);

                    break;

                default:

                    shot s7 = new shot(hero.Center, false);
                    shot s8 = new shot(hero.Center, false);
                    shot s9 = new shot(hero.Center, false);
                    shot s10 = new shot(hero.Center, false);

                    s7.bullet.ShouldTravel = true;
                    s8.bullet.ShouldTravel = true;
                    s9.bullet.ShouldTravel = true;
                    s10.bullet.ShouldTravel = true;

                    velDir =
                        (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0)
                        ? new Vector2(hero.Texture == "newPrincessRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;

                    if (velDir.X < 0f && velDir.Y < 0f) {
                        s7.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                        s8.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                        s9.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                        s10.bullet.VelocityDirection = new Vector2(velDir.X * -1f, velDir.Y * -1f);
                    }

                    else if (velDir.Y < 0f && velDir.X > 0f) {
                        s7.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                        s8.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y - .1f);
                        s9.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y + .1f);
                        s10.bullet.VelocityDirection = new Vector2(velDir.X * -1f, velDir.Y * -1f);
                    }

                    else if (velDir.Y > 0f && velDir.X < 0f) {
                        s7.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                        s8.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y);
                        s9.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y);
                        s10.bullet.VelocityDirection = new Vector2(velDir.X * -1f, velDir.Y * -1f);
                    }

                    else {
                        s7.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                        s8.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                        s9.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                        s10.bullet.VelocityDirection = new Vector2(velDir.X * -1f, velDir.Y * -1f);
                    }

                    list.Add(s7);
                    list.Add(s8);
                    list.Add(s9);
                    list.Add(s10);
                    break;

            }
        }
Exemplo n.º 17
0
    public void NextSpawner()
    {
        numBlocks++;
        if (numBlocks % 10 == 0)
        {
            shot other = (shot)GameObject.Find("hand_right").GetComponent(typeof(shot));
            other.AddAmmo();
        }

        // Random Index
        if (currentSel == -1)
        {
            currentSel = Random.Range(0, groups.Length);
            nextSel    = Random.Range(0, groups.Length);
            //Instantiate(groups[currentSel], startPos, Quaternion.identity);
            nextSel = 0;
        }
        else
        {
            currentSel = nextSel;
            nextSel    = Random.Range(0, groups.Length);
            GameObject nextGene = GameObject.Find("model");
            //if(nextGene.tag != "dontDestroy")
            Destroy(nextGene);
        }

        if (!NextUserDesignModel)
        {
            Instantiate(groups[currentSel], startPos, Quaternion.identity);
            var model = Instantiate(groups[nextSel], nextPos, Quaternion.identity);
            model.GetComponent <Group>().enabled = false;
            model.name = "model";
            model.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
        }
        else if (timeFlag == 1)
        {
            diyCount++;
            userDesignModel = GameObject.Find("DIYobj");
            Instantiate(groups[currentSel], startPos, Quaternion.identity);
            var model = Instantiate(userDesignModel, nextPos, Quaternion.identity);
            model.GetComponent <Group>().enabled = false;
            model.name = "miao" + diyCount.ToString();
            //model.transform.localScale = new Vector3(2.5f, 2.5f, 2.5f);
            Vector3 basePos = model.transform.GetChild(0).localPosition;
            for (int i = 0; i < userDesignModel.transform.childCount; i++)
            {
                model.transform.GetChild(i).localPosition -= basePos;
                Destroy(userDesignModel.transform.GetChild(i).gameObject);
            }

            timeFlag++;
        }
        else
        {
            userDesignModel = GameObject.Find("miao" + diyCount.ToString());
            userDesignModel.GetComponent <Group>().enabled = true;
            //userDesignModel.transform.localScale = new Vector3(5f, 5f, 5f);
            userDesignModel.transform.position = startPos;
            var model = Instantiate(groups[nextSel], nextPos, Quaternion.identity);
            model.GetComponent <Group>().enabled = false;
            model.name = "model";
            model.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            timeFlag            = 1;
            NextUserDesignModel = false;
            //userDesignModel.GetComponent<Group>().enabled = false;
        }
    }
Exemplo n.º 18
0
 public getTinta(shot tinta)
 {
     return(this.tinta);
 }
Exemplo n.º 19
0
        public bool Update(Hero hero, Wand w)
        {
            heroHit = false;
            health.Update(new Vector2(this.Center.X, this.Center.Y + 1), healthRemaining, initialLives);

            if (current == wizardStatus.isAlive)
            {
                if (shieldCoolDown < 0 && !shielded)
                {
                    shielded       = true;
                    shieldCoolDown = 100;
                }
                else
                {
                    shieldCoolDown--;
                }

                if (shieldCoolDown < 0 && shielded)
                {
                    shielded       = false;
                    shieldCoolDown = 100;
                }


                if (shielded)
                {
                    Texture = "wizardShield";
                }
                else
                {
                    Texture = "wizardRight";
                    if (coolDown < 0)
                    {
                        coolDown = 40;
                        shoot(hero.Center);
                    }
                    else
                    {
                        coolDown--;
                    }
                }

                for (int i = 0; i < list.Count; i++)
                {
                    shot temp = list[i];
                    if (list[i].shotLife == 0)
                    {
                        list[i].bullet.RemoveFromAutoDrawSet();
                        list[i].emitter.RemoveFromAutoDrawSet();
                        list.Remove(list[i]);
                    }
                    else
                    {
                        temp.shotLife--;
                        if (hero.Collided(temp.bullet) && !temp.hit)
                        {
                            hero.Caught();
                            hero.Center = hero.HeroInitialPos;
                            temp.hit    = true;
                            heroHit     = true;
                        }
                        list[i] = temp;
                        list[i].emitter.Center = list[i].bullet.Center;
                    }
                }
                for (int i = 0; i < w.list.Count; i++)
                {
                    if (w.list[i].bullet.Collided(this))
                    {
                        if (!shielded)
                        {
                            healthRemaining--;
                        }
                        else
                        {
                            Random r = new Random();
                            if (r.Next(0, 100) < 10)
                            {
                                healthRemaining--;
                            }
                        }
                    }
                }

                if (healthRemaining <= 0)
                {
                    current = wizardStatus.isDead;
                    Texture = "Newteddybear";
                    XNACS1Base.PlayACue("Bear-Sound");

                    return(true);
                }

                if (this.Center.X - hero.Center.X > 0)
                {
                    Texture = shielded ? "wizardShieldLeft" : "wizardLeft";
                }
                else
                {
                    Texture = shielded ? "wizardShield" : "wizardRight";
                }
            }

            if (current == wizardStatus.isDead)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    list[i].bullet.RemoveFromAutoDrawSet();
                    list[i].emitter.RemoveFromAutoDrawSet();
                    list.Remove(list[i]);
                }
            }
            return(false);
        }
Exemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        bool trigger = OVRInput.Get(OVRInput.Button.SecondaryHandTrigger);
        shot s       = (shot)GameObject.Find("hand_right").GetComponent(typeof(shot));

        if (s.mode == 0)
        {
            if (trigger)
            {
                Vector3 contRot = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch).eulerAngles;

                Debug.Log(transform.position.x);
                if (contRot.x < 300.0f && contRot.x > 240.0f)
                {
                    if (transform.position.y < 25.0f)
                    {
                        transform.position += Vector3.up * 0.1f;
                    }
                }
                else if (contRot.x > 20.0f && contRot.x < 80.0f)
                {
                    if (transform.position.y > 7.0f)
                    {
                        transform.position += Vector3.down * 0.1f;
                    }
                }
                else if (contRot.z < 320.0f && contRot.z > 260.0f)
                {
                    if (transform.position.x < 6.0f)
                    {
                        transform.position += Vector3.right * 0.1f;
                    }
                }
                else if (contRot.z > 40.0f && contRot.z < 100.0f)
                {
                    if (transform.position.x > -2.0f)
                    {
                        transform.position += Vector3.left * 0.1f;
                    }
                }
            }
        }
        else
        {
            if (s.objToDrag && trigger)
            {
                Vector3 contRot = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch).eulerAngles;
                Debug.Log(s.objToDrag.transform.position);

                if (contRot.x < 300.0f && contRot.x > 240.0f)
                {
                    if (lastDir != 1 && s.objToDrag.transform.position.y < 3.0f)
                    {
                        s.objToDrag.transform.position += Vector3.up;
                    }
                    lastDir = 1;
                }
                else if (contRot.x > 20.0f && contRot.x < 80.0f)
                {
                    if (lastDir != 2 && s.objToDrag.transform.position.y > 0.0f)
                    {
                        s.objToDrag.transform.position += Vector3.down;
                    }
                    lastDir = 2;
                }
                else if (contRot.z > 40.0f && contRot.z < 100.0f)
                {
                    if (lastDir != 3 && s.objToDrag.transform.position.z > 0.0f)
                    {
                        s.objToDrag.transform.position += Vector3.back;
                    }
                    lastDir = 3;
                }
                else if (contRot.z < 320.0f && contRot.z > 260.0f)
                {
                    if (lastDir != 4 && s.objToDrag.transform.position.z < 3.0f)
                    {
                        s.objToDrag.transform.position += Vector3.forward;
                    }
                    lastDir = 4;
                }
                else
                {
                    lastDir = 0;
                }
            }
        }
    }
Exemplo n.º 21
0
        public void Shoot(XNACS1Rectangle hero)
        {
            Vector2 velDir;

            XNACS1Base.PlayACue("spell");
            switch (level)
            {
            case 0:
                shot s = new shot(hero.Center, false);
                s.bullet.ShouldTravel      = true;
                s.bullet.VelocityDirection =
                    (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0)
                                                ? new Vector2(hero.Texture == "newPrincessRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;
                list.Add(s);
                break;

            case 1:
                shot s2 = new shot(hero.Center, false);
                shot s3 = new shot(hero.Center, false);

                velDir =
                    (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0)
                                                ? new Vector2(hero.Texture == "newPrincessRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;



                if (velDir.X < 0f && velDir.Y < 0f)
                {
                    s2.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                    s3.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                }

                else if (velDir.Y < 0f && velDir.X > 0f)
                {
                    s2.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y - .1f);
                    s3.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y + .1f);
                }

                else if (velDir.Y > 0f && velDir.X < 0f)
                {
                    s2.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y);
                    s3.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y);
                }

                else
                {
                    s2.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                    s3.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                }

                s2.bullet.ShouldTravel = true;
                s3.bullet.ShouldTravel = true;
                list.Add(s2);
                list.Add(s3);

                break;

            case 2:
                shot s4 = new shot(hero.Center, false);
                shot s5 = new shot(hero.Center, false);
                shot s6 = new shot(hero.Center, false);

                s4.bullet.ShouldTravel = true;
                s5.bullet.ShouldTravel = true;
                s6.bullet.ShouldTravel = true;


                velDir =
                    (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0)
                                                ? new Vector2(hero.Texture == "newPrincessRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;


                if (velDir.X < 0f && velDir.Y < 0f)
                {
                    s4.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                    s5.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                    s6.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                }

                else if (velDir.Y < 0f && velDir.X > 0f)
                {
                    s4.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                    s5.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y - .1f);
                    s6.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y + .1f);
                }

                else if (velDir.Y > 0f && velDir.X < 0f)
                {
                    s4.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                    s5.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y);
                    s6.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y);
                }

                else
                {
                    s4.bullet.VelocityDirection = new Vector2(velDir.X, velDir.Y);
                    s5.bullet.VelocityDirection = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                    s6.bullet.VelocityDirection = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                }

                list.Add(s4);
                list.Add(s5);
                list.Add(s6);

                break;

            default:

                shot s7  = new shot(hero.Center, false);
                shot s8  = new shot(hero.Center, false);
                shot s9  = new shot(hero.Center, false);
                shot s10 = new shot(hero.Center, false);

                s7.bullet.ShouldTravel  = true;
                s8.bullet.ShouldTravel  = true;
                s9.bullet.ShouldTravel  = true;
                s10.bullet.ShouldTravel = true;

                velDir =
                    (XNACS1Base.GamePad.ThumbSticks.Right.X == 0 && XNACS1Base.GamePad.ThumbSticks.Right.Y == 0)
                                                ? new Vector2(hero.Texture == "newPrincessRight" ? 1 : -1, 0) : XNACS1Base.GamePad.ThumbSticks.Right;


                if (velDir.X < 0f && velDir.Y < 0f)
                {
                    s7.bullet.VelocityDirection  = new Vector2(velDir.X, velDir.Y);
                    s8.bullet.VelocityDirection  = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                    s9.bullet.VelocityDirection  = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                    s10.bullet.VelocityDirection = new Vector2(velDir.X * -1f, velDir.Y * -1f);
                }

                else if (velDir.Y < 0f && velDir.X > 0f)
                {
                    s7.bullet.VelocityDirection  = new Vector2(velDir.X, velDir.Y);
                    s8.bullet.VelocityDirection  = new Vector2(velDir.X, velDir.Y - .1f);
                    s9.bullet.VelocityDirection  = new Vector2(velDir.X, velDir.Y + .1f);
                    s10.bullet.VelocityDirection = new Vector2(velDir.X * -1f, velDir.Y * -1f);
                }

                else if (velDir.Y > 0f && velDir.X < 0f)
                {
                    s7.bullet.VelocityDirection  = new Vector2(velDir.X, velDir.Y);
                    s8.bullet.VelocityDirection  = new Vector2(velDir.X - .1f, velDir.Y);
                    s9.bullet.VelocityDirection  = new Vector2(velDir.X + .1f, velDir.Y);
                    s10.bullet.VelocityDirection = new Vector2(velDir.X * -1f, velDir.Y * -1f);
                }

                else
                {
                    s7.bullet.VelocityDirection  = new Vector2(velDir.X, velDir.Y);
                    s8.bullet.VelocityDirection  = new Vector2(velDir.X + .1f, velDir.Y - .1f);
                    s9.bullet.VelocityDirection  = new Vector2(velDir.X - .1f, velDir.Y + .1f);
                    s10.bullet.VelocityDirection = new Vector2(velDir.X * -1f, velDir.Y * -1f);
                }


                list.Add(s7);
                list.Add(s8);
                list.Add(s9);
                list.Add(s10);
                break;
            }
        }
Exemplo n.º 22
0
 private void shoot(Vector2 target)
 {
     shot s = new shot(this.Center, false);
     s.bullet.ShouldTravel = true;
     s.bullet.VelocityDirection = target - Center;
     list.Add(s);
 }