public void Turn(string name, string GUID, ShootType type, int x, int y)
 {
     if (clientsDictionary.ContainsKey(name) && clientsDictionary[name].CheckGUID(GUID))
     {
         if (!clientsDictionary[name].HaveGame)
         {
             Console.WriteLine("Cliente {0} no esta jugando ahora!)", name);
             try
             {
                 clientsDictionary[name].Callback.FatalError("Usted no está jugando ahora!");
             }
             catch (Exception)
             {
                 SecureDeleteClient(clientsDictionary[name]);
             }
             return;
         }
         Console.WriteLine("Cliente {0} hizo un turno!", name);
         clientsDictionary[name].DoTurn(x, y);
         return;
     }
     Console.WriteLine("Cliente desconocido: ({0}, {1}) quiere disparar (todos quieren)!", name, GUID);
     try
     {
         OperationContext.Current.GetCallbackChannel <IClientCallback>().FatalError("el Servidor dijo: no te conozco!");
     }
     catch (Exception) { }
 }
Ejemplo n.º 2
0
 public BaseWeapon(WeaponClass weaponClass, ShootType shootType, int maxAmmo)
 {
     this.shootType   = shootType;
     this.weaponClass = weaponClass;
     ammo             = maxAmmo;
     this.maxAmmo     = maxAmmo;
 }
Ejemplo n.º 3
0
        // Movement states:
        //  - moving
        //  - stopped
        //  - paused
        //  - chasing
        //  - shooting??

        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------

        public BasicMonster()
        {
            color         = MonsterColor.Red;
            MaxHealth     = 1;
            ContactDamage = 1;

            scaleAnimationSpeed         = false;
            playAnimationOnlyWhenMoving = true;
            isAnimationHorizontal       = false;

            moveSpeed = 0.5f;
            changeDirectionsOnCollide  = true;
            syncAnimationWithDirection = true;
            movesInAir = false;
            stopTime.Set(30, 60);
            moveTime.Set(30, 50);

            chargeType     = ChargeType.None;
            chargeDuration = RangeI.Zero;

            shootType           = ShootType.None;
            aimType             = AimType.Forward;
            projectileType      = null;
            shootSpeed          = 2.0f;
            projectileShootOdds = 5;
            shootPauseDuration  = 30;
            shootSound          = null;
        }
Ejemplo n.º 4
0
    /* ChangeShootType
     *
     * changes turret's shoot type
     *
     * first -> last -> mostHealth -> closest
     *
     */
    public void ChangeShootType()
    {
        Debug.Log("changing type");

        ShootType shootType = target.turret.GetComponent <Turret>().shootType;

        if (shootType == ShootType.First)
        {
            shootType = ShootType.Last;
        }
        else if (shootType == ShootType.Last)
        {
            shootType = ShootType.MostHealth;
        }
        else if (shootType == ShootType.MostHealth)
        {
            shootType = ShootType.Closest;
        }
        else if (shootType == ShootType.Closest)
        {
            shootType = ShootType.First;
        }

        target.turret.GetComponent <Turret>().shootType = shootType;

        SetTarget(target);
    }
Ejemplo n.º 5
0
    IEnumerator Shoot(ShootType type)
    {
        if(shootType == ShootType.Type1)
        {
            Transform bullet1 = Instantiate(bulletPrefab, transform.GetChild(1).transform.position, Quaternion.identity)as Transform;
            bullet1.GetComponent<Bullet>().direction = -transform.forward;
            yield return new WaitForSeconds(2.0f);
            Transform bullet2 = Instantiate(bulletPrefab, transform.GetChild(0).transform.position, Quaternion.identity) as Transform;
            bullet2.GetComponent<Bullet>().direction = -transform.forward;
            Transform bullet3 = Instantiate(bulletPrefab, transform.GetChild(2).transform.position, Quaternion.identity) as Transform;
            bullet3.GetComponent<Bullet>().direction = -transform.forward;

            shootType = ShootType.Type2;
        }
        else if(shootType == ShootType.Type2)
        {
            Transform bullet1 = Instantiate(bulletPrefab, transform.GetChild(0).transform.position, Quaternion.identity)as Transform;
            bullet1.GetComponent<Bullet>().direction = -transform.forward;
            yield return new WaitForSeconds(1.0f);;
            Transform bullet2 = Instantiate(bulletPrefab, transform.GetChild(1).transform.position, Quaternion.identity) as Transform;
            bullet2.GetComponent<Bullet>().direction = -transform.forward;
            yield return new WaitForSeconds(2.5f);
            Transform bullet3 = Instantiate(bulletPrefab, transform.GetChild(2).transform.position, Quaternion.identity) as Transform;
            bullet3.GetComponent<Bullet>().direction = -transform.forward;

            shootType = ShootType.Type1;
        }
    }
Ejemplo n.º 6
0
    void Start()
    {
        //transform.position = TileMapGenerator.instance.tileMapCorridor[TileMapGenerator.instance.CorridorLarger-3].GetPosition();

        shootType = ShootType.Type1;

        StartCoroutine(CannonShoot(6.0f));
    }
Ejemplo n.º 7
0
 public void init(uint id, ShootType type, Vector3 velocity, float angle, Vector3 target)
 {
     base.init(id);
     shootType     = (uint)type;
     this.velocity = velocity;
     this.angle    = angle;
     this.target   = target;
 }
Ejemplo n.º 8
0
 public PlayerObjectParameter(Vector3 pos, bool hasGravity = true, bool hasJumps = true,
                              MovementType movementType    = MovementType.Continuos,
                              ShootType shootType          = ShootType.CreateBullet) : base(pos)
 {
     this.hasGravity   = hasGravity;
     this.hasJumps     = hasJumps;
     this.movementType = movementType;
     this.shootType    = shootType;
 }
Ejemplo n.º 9
0
 public EBTStatus shoot(ShootType type)
 {
     if (!actor.shootBallEvent)
     {
         actor.world.shootBallDirectly(actor, type);
         state = PlayerState.Shoot;
     }
     return(EBTStatus.BT_RUNNING);
 }
Ejemplo n.º 10
0
 public Gun(Bullet bullet, int capacity, float reloadSpeed, float fireRate, ShootType shootType)
 {
     _bullet      = bullet;
     _capacity    = capacity;
     _roundsNum   = _capacity;
     _reloadSpeed = reloadSpeed;
     _fireRate    = fireRate;
     _shootType   = shootType;
 }
Ejemplo n.º 11
0
 public UnitOfWork(photostudioContext context)
 {
     _context     = context;
     Photos       = new PhotoRepository(_context);
     Schedules    = new ScheduleRepository(_context);
     Appointments = new AppointmentRepository(_context);
     Contacts     = new ContactRepository(_context);
     Feedbacks    = new FeedbackRepository(_context);
     ShootTypes   = new ShootType(_context);
 }
Ejemplo n.º 12
0
    public void shootBallDirectly(FBActor actor, ShootType type)
    {
        var direction = (actor.getEnemyDoorPosition() - actor.getPosition()).normalized;

        FixVector2 doorPosition  = FixVector2.kZero;
        FixVector2 destDirection = FixVector2.kZero;

        positiveDoorSide = getDoorSide(actor, direction, out destDirection);
        actor.shootBallDirectly(type, direction);
    }
Ejemplo n.º 13
0
 public int          bulletCount; // In the case of shoot type circle burst
 public EnemyConfig(MovementType movementType, ShootType shootType, Vector3 pos, float fdm, float ssm, float bsm, string hval, int bCnt)
 {
     this.movementType = movementType;
     this.shootType    = shootType;
     position          = pos;
     shotDelay         = fdm;
     shipSpeedMult     = ssm;
     bulletSpeedMult   = bsm;
     heldValue         = hval;
     bulletCount       = bCnt;
 }
Ejemplo n.º 14
0
    private void Shoot()
    {
        refreshDelta = 0;
        bulletType   = BulletType.Normal;
        SoundManager.Instance.PlayShootSound();
        if (Physics.Raycast(mainCamera.transform.position, mainCamera.transform.forward, out hit, 100f))
        {
            if (hit.collider.CompareTag("Victim"))
            {
                shootType = ShootType.Victim;
                if (hit.transform.GetComponent <Victim>().victimType == VictimType.Normal)
                {
                    hit.transform.GetComponent <Victim>().sequence.Pause();
                    hit.transform.GetComponent <Victim>().victimAnim.enabled = false;
                }
                SpawnBullet();
                int val = UnityEngine.Random.Range(0, 100);
                bulletType = val % 2 == 0 ? BulletType.Normal : BulletType.WithCamera;

                if (bulletType == BulletType.WithCamera)
                {
                    weaponCamera.SetActive(false);
                    imgScope.SetActive(false);
                    Vector3 camPos = new Vector3(0, 0, -1.5f);
                    sequence = DOTween.Sequence();
                    sequence.AppendInterval(.1f).Append(mainCamera.transform.DOMove(hit.point + camPos, .4f));
                    Time.timeScale = .4f;
                }
            }
            else if (hit.collider.CompareTag("Destroyable"))
            {
                shootType = ShootType.Destroyable;
                SpawnBullet();
            }
            else if (hit.collider.CompareTag("Explosive"))
            {
                shootType = ShootType.Explosive;

                SpawnBullet();
                SoundManager.Instance.PlayExplosiveSound();
            }
            else
            {
                Instantiate(FxManager.Instance.bulletImpactFXDefault, hit.point, Quaternion.LookRotation(hit.normal));
                //shoot = false;
                ScopeOut();
            }
        }
        else
        {
            //shoot = false;
            ScopeOut();
        }
    }
Ejemplo n.º 15
0
 public EBTStatus charge(ShootType type)
 {
     if (state != PlayerState.Charge)
     {
         world.beginCheckShootBall(FixVector2.kZero);
         state      = PlayerState.Charge;
         chargeTime = getChargeTime(type);
         timer      = Fix64.Zero;
     }
     return((actor.checkShootBallState() && timer < chargeTime) ? EBTStatus.BT_RUNNING : EBTStatus.BT_SUCCESS);
 }
Ejemplo n.º 16
0
 public EnemyConfig(EnemyConfig ec, string hval)      // clumsy but fast fix for the lesson that structs are immutable...
 {
     movementType    = ec.movementType;
     shootType       = ec.shootType;
     position        = ec.position;
     shotDelay       = ec.shotDelay;
     shipSpeedMult   = ec.shipSpeedMult;
     bulletSpeedMult = ec.bulletSpeedMult;
     heldValue       = hval;
     bulletCount     = ec.bulletCount;
 }
Ejemplo n.º 17
0
 void Start()
 {
     gameManager = GameObject.Find("Game Manager");           // finds the game manager
     bulletManager = gameManager.GetComponent<BulletManager>();    // gets the gameManager's bullet manager Script
     shootType = (ShootType)PlayerPrefs.GetInt("ShotType") - 1; // sets the shooting type to normal by default
     if (shootType < 0)
     {
         shootType = 0;
     }
     shootCooldown -= shotSpeedIncreasePerLevel * PlayerPrefs.GetInt("Speed");
     // Time.timeScale = 0.01f;
 }
Ejemplo n.º 18
0
 public Player(Vector3 pos, bool hasGravity = true, bool hasJumps = true,
               MovementType movementType    = MovementType.Continuos, ShootType shootType = ShootType.CreateBullet) : this()
 {
     Position          = pos;
     this.movementType = movementType;
     this.hasGravity   = hasGravity;
     this.shootType    = shootType;
     if (movementType == MovementType.NoAcceleration || movementType == MovementType.UserAcceleration)
     {
         defaultSpeedX = 0;
     }
 }
Ejemplo n.º 19
0
    public void shootBallDirectly(ShootType shootType, FixVector2 direction)
    {
        if (!this.isCtrlBall())
        {
            return;
        }

        doShootBall(direction);
        m_stateDataIndex  = (int)shootType;
        shootingType      = shootType;
        shootBallEvent    = true;
        _shootBallPressed = false;
        _shootBallTimeSum = Fix64.Zero;
    }
Ejemplo n.º 20
0
    Fix64 getChargeTime(ShootType type)
    {
        switch (type)
        {
        case ShootType.Normal:
            return(world.randomUnit * ConstTable.HardShootPressTime);

        case ShootType.Power:
            return(ConstTable.HardShootPressTime + (Fix64)0.9 * world.randomUnit * (ConstTable.SuperShootPressTime - ConstTable.HardShootPressTime));

        case ShootType.Super:
        case ShootType.Killer:
            return(ConstTable.SuperShootPressTime);
        }
        return(Fix64.Zero);
    }
Ejemplo n.º 21
0
        public async Task <IActionResult> EditShootType(int id, ShootType shootType)
        {
            if (ModelState.IsValid)
            {
                if (await unitOfWork.ShootTypes.Get(id) == null)
                {
                    return(UnprocessableEntity("Değiştirmek istediğiniz çekim türü bulunamadı. Lütfen tekrar deneyiniz!"));
                }

                unitOfWork.ShootTypes.Update(shootType);
                await unitOfWork.Complete();

                return(Ok("Başarıyla güncellendi!"));
            }
            return(BadRequest("Başarısız. Lütfen tekrar deneyiniz!"));
        }
Ejemplo n.º 22
0
    IEnumerator forceHoldFire(Ability irl)
    {
        irl.canMoveOn = true;
        var v = father.shootType;

        father.shootType        = remember;
        father.orderOverwriteST = remember;
        remember = v;
        if (father.shootType == ShootType.NoShoot)
        {
            irl.ChangeSpriteTo(AbilitySprite.Explosion);
        }
        else
        {
            irl.ChangeSpriteTo(AbilitySprite.HoldFire);
        }
        yield return(null);
    }
Ejemplo n.º 23
0
    /// <summary>
    /// Executa uma jogada a depender do tipo de jogada.
    /// </summary>
    /// <param name="play"> O tipo de jogada</param>
    void doPlay(PlayType play)
    {
        switch (play)
        {
        case PlayType.MOVE:
            moveTo(getRandomPosition());
            break;

        case PlayType.SHOOT:
            System.Array values    = System.Enum.GetValues(typeof(ShootType));
            ShootType    shootType = (ShootType)values.GetValue(Random.Range(0, values.Length));
            shoot(shootType, 5, Random.Range(2, 5));
            break;

        case PlayType.TELEPORT:
            teleportTo(getRandomPosition());
            break;
        }
    }
Ejemplo n.º 24
0
    void shoot(ShootType s, float velocity, int quantity)
    {
        switch (s)
        {
        case ShootType.ALL:
            foreach (GameObject weapon in weapons)
            {
                currentPlayCoroutine = StartCoroutine(shootXTimes(quantity, velocity, 0.5f, weapon.transform.localRotation));     //Atira com todas as armas do atributo weapons dessa classe
            }
            break;

        case ShootType.HALF:     //Tipo de tipo removido para nerfar o boss.
            break;

        case ShootType.ONE:
            currentPlayCoroutine = StartCoroutine(shootXTimes(quantity, velocity, 0.5f, Quaternion.Euler(0, 0, -90)));   //Atira para baixo n vezes
            break;
        }
    }
Ejemplo n.º 25
0
 private void ChangeWeapon()
 {
     if (Input.GetAxis("Mouse ScrollWheel") > 0)
     {
         Type += 1;
         if ((int)Type > 1)
         {
             Type = 0;
         }
     }
     else if (Input.GetAxis("Mouse ScrollWheel") < 0)
     {
         Type -= 1;
         if ((int)Type < 0)
         {
             Type += 2;
         }
     }
 }
Ejemplo n.º 26
0
    public void shoot(ShootType type)
    {
        switch (type)
        {
        case ShootType.Normal:
            showStrikeEffect(normalStrikeEffect, EffectType.BallPosition, Vector3.zero);
            break;

        case ShootType.Power:
            break;

        case ShootType.Super:
            //showStrikeEffect(superStrikeEffect, EffectType.BallPosition);
            break;

        case ShootType.Killer:
            break;
        }
    }
Ejemplo n.º 27
0
        public async Task <IActionResult> CreateShootType(ShootTypeView shootTypeView)
        {
            if (ModelState.IsValid)
            {
                if (shootTypeView.Photo == null || !shootTypeView.Photo.ContentType.Contains("image"))
                {
                    return(BadRequest("Geçersiz Dosya Türü Lütfen bir fotoğraf seçiniz."));
                }

                try
                {
                    var amazon = new AmazonS3Service(
                        appSettings.Value.AccessKey,
                        appSettings.Value.SecretAccessKey,
                        appSettings.Value.BucketName);


                    var response = await amazon.UploadFileAsync(file : shootTypeView.Photo, subFolderName : "ShootTypePhotos");

                    if (response.Success)
                    {
                        var shootType = new ShootType()
                        {
                            Name        = shootTypeView.Name,
                            IsActive    = shootTypeView.IsActive,
                            Icon        = shootTypeView.Icon,
                            Description = shootTypeView.Description,
                            PhotoPath   = response.ThumbnailUrl
                        };
                        await unitOfWork.ShootTypes.Add(shootType);

                        await unitOfWork.Complete();

                        return(Ok("Çekim Türü başarıyla eklendi."));
                    }
                }
                catch (Exception)
                {
                }
            }
            return(BadRequest("Başarısız. Lütfen eksik alan bırakmayınız. Fotoğraf ve İkon seçilmesi gerek."));
        }
Ejemplo n.º 28
0
    FixVector3 getActorShootOutPosition(FBActor actor, ShootType shootType)
    {
        BallDetachType bt = BallDetachType.NormalShoot;

        if (shootType == ShootType.Normal)
        {
            bt = BallDetachType.NormalShoot;
        }
        else if (shootType == ShootType.Power)
        {
            bt = BallDetachType.PowerShoot;
        }
        else if (shootType == ShootType.Super)
        {
            bt = BallDetachType.SuperShoot;
        }
        else if (shootType == ShootType.Killer)
        {
            bt = BallDetachType.KillerShoot;
        }
        return(actor.getBallPosition(bt));
    }
Ejemplo n.º 29
0
    public void shoot(ShootType type,
                      Vector3 velocity,
                      float angle,
                      Vector3 target,
                      ActorView shooter)
    {
        shootType = type;

        switch (type)
        {
        case ShootType.Normal:
            showTrailEffect(config.normalTrailEffect);
            setRotateType(velocity);
            break;

        case ShootType.Power:
            showTrailEffect(config.powerTrailEffect);
            setRotateType(velocity);
            break;

        case ShootType.Super:
            showTrailEffect(config.getSuperTrailEffect(shooter.element));
            rotator.arcline(angle);
            break;

        case ShootType.Killer:
            showTrailEffect(shooter.name + "_" + config.killerTrailEffect);

            var dir    = target - transform.position;
            var matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.LookRotation(dir), Vector3.one);

            var killerSkillRotate = config.getKillerSkillRotate(shooter.roleId);
            var axis = matrix.MultiplyVector(killerSkillRotate.axis).normalized;
            rotator.killerSkill(axis, killerSkillRotate.angularVelocity);
            break;
        }
    }
Ejemplo n.º 30
0
    //------------Generate Enemies from parameters
    List <EnemyConfig> GetEnemies(LevelParams lp, List <Question> qs)
    {
        List <EnemyConfig> outCfg = new List <EnemyConfig>();
        // pick random number of enemy ships between specified level params, making sure we have enough to cover all questions
        int shipcount = Random.Range(Mathf.Max(lp.shipCountRange.x, qs.Count), Mathf.Max(lp.shipCountRange.y, qs.Count));
        int row       = MAXROWS - 1; // The row selection should be random, but starting from back for now

        if (shipcount > 9 || shipcount < 2)
        {
            Debug.LogWarningFormat("I'm not prepared to handle only {0} ship(s)", shipcount);
            return(outCfg);
        }
        while (shipcount != 0 || row >= 0)
        {
            int s = Random.Range(1, 4); // pick number between 1 and 3 for # ships per row
            if (shipcount < s)
            {
                s         = shipcount;
                shipcount = 0;
            }
            else
            {
                shipcount -= s;
            }
            float spacing = width / (s + 1);
            float startx  = spacing - width / 2f;
            for (int i = 0; i < s; i++)
            {
                MovementType     mt           = (MovementType)Random.Range(0, System.Enum.GetNames(typeof(MovementType)).Length); // random movement type
                List <ShootType> availAttacks = System.Enum.GetValues(typeof(ShootType)).Cast <ShootType>().ToList();             // list of all actions at first
                switch (mt)
                {
                case MovementType.Static:
                    availAttacks.Remove(ShootType.None);
                    break;

                case MovementType.Horizontal:
                    availAttacks.Remove(ShootType.CircleBurst);
                    break;

                case MovementType.Circle:
                    availAttacks.Remove(ShootType.CircleBurst);
                    break;
                }

                ShootType at          = availAttacks[Random.Range(0, availAttacks.Count)];
                float     shotDelay   = Random.Range(lp.shotDelayRange.x, lp.shotDelayRange.y);
                float     moveSpeed   = Random.Range(lp.speedRange.x, lp.speedRange.y);
                float     bulletSpeed = lp.bulletSpeed;
                int       bulletCount = 0;
                if (at == ShootType.CircleBurst) // if we're a circle burst, we need to set addtl parameters
                {
                    bulletCount = 12;
                    bulletSpeed = bulletSpeed / 2.5f; //Reduce the speed here, it's pretty wacky if too fast
                    shotDelay   = shotDelay * 2.0f;   //Also so many bullets, slow em down
                }
                Debug.LogFormat("Row: {0}", row);
                Vector3 pos = new Vector3(startx + spacing * i, rowPos[row], 0f) - posOffset;
                string  ans = Random.Range(FAKEMIN, FAKEMAX).ToString(); // Get fake ans (ok if randomly matches right ans for now)
                outCfg.Add(new EnemyConfig(mt, at, pos, shotDelay, moveSpeed, bulletSpeed, ans, bulletCount));
            }
            row--;
        }
        //Now that you've got the ships in the correct positions, add the held values
        if (qs.Count > outCfg.Count)
        {
            Debug.LogErrorFormat("Somehow we have more questions than ships to put ans on? {0} > {1}", qs.Count, outCfg.Count);
        }

        List <int> posAvail = Enumerable.Range(0, outCfg.Count).ToList(); // get list of places where we could put answers so we don't double up

        foreach (Question q in qs)
        {
            int pos = Random.Range(0, posAvail.Count);
            int idx = posAvail[pos];
            posAvail.RemoveAt(pos);
            EnemyConfig cfg = outCfg[idx];
            outCfg[idx] = new EnemyConfig(cfg, q.ans); // update cfg with new answer, this is a pretty kludgey way to get around struct immutability
        }
        return(outCfg);
    }
Ejemplo n.º 31
0
 public void Turn(string name, string GUID, ShootType type, int x, int y)
 {
     if (clientsDictionary.ContainsKey(name) && clientsDictionary[name].CheckGUID(GUID))
     {
         if (!clientsDictionary[name].HaveGame)
         {
             Console.WriteLine("Client {0} not gaming now!)", name);
             try
             {
                 clientsDictionary[name].Callback.FatalError("You are not gaming now!");
             }
             catch (Exception)
             {
                 SecureDeleteClient(clientsDictionary[name]);
             }
             return;
         }
         Console.WriteLine("Client {0} did a turn!", name);
         clientsDictionary[name].DoTurn(x, y);
         return;
     }
     Console.WriteLine("Unknown client: ({0}, {1}) wants to shoot (everybody wants)!", name, GUID);
     try
     {
         OperationContext.Current.GetCallbackChannel<IClientCallback>().FatalError("Server don't know you!");
     }
     catch (Exception) { }
 }
Ejemplo n.º 32
0
 public void init(uint id, ShootType shootType)
 {
     base.init(id);
     this.shootType = (uint)shootType;
 }
        // Movement states:
        //  - moving
        //  - stopped
        //  - paused
        //  - chasing
        //  - shooting??
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public BasicMonsterOld()
        {
            color			= MonsterColor.Red;
            MaxHealth		= 1;
            ContactDamage	= 1;

            scaleAnimationSpeed			= false;
            playAnimationOnlyWhenMoving	= true;
            isAnimationHorizontal		= false;

            moveSpeed					= 0.5f;
            numMoveAngles				= 4;
            isMovementDirectionBased	= true;
            changeDirectionsOnCollide	= true;
            syncAnimationWithDirection	= true;
            movesInAir					= false;
            stopTime.Set(30, 60);
            moveTime.Set(30, 50);

            chargeType			= ChargeType.None;
            chargeDuration		= RangeI.Zero;

            shootType			= ShootType.None;
            aimType				= AimType.Forward;
            projectileType		= null;
            shootSpeed			= 2.0f;
            projectileShootOdds	= 5;
            shootPauseDuration	= 30;
        }
Ejemplo n.º 34
0
 public void FixOrderOverwrites()
 {
     msa       = orderOverwriteMSA;
     shootType = orderOverwriteST;
 }
Ejemplo n.º 35
0
    void Update()
    {
        RaycastHit hit;

        Physics.Raycast(new Ray(transform.position, Vector3.down), out hit, Mathf.Infinity, GameMaster.singleton.groundOnly);
        if (mover.agent == null)
        {
            transform.position = new Vector3(transform.position.x, hit.point.y + prefferedHeight + (bcollider.center.y + bcollider.bounds.size.y), transform.position.z);
        }
        visVision.transform.position = new Vector3(transform.position.x, hit.point.y + 0.01f, transform.position.z);
        orderLine.Hide();
        myTile.transform.position  = GameMaster.singleton.calculateTilePosition(gameObject);
        zosIcon.transform.position = myTile.transform.position;
        // bool move = true;
        if (msa == MSA_Type.StopOnShoot && (ds.closest != null || target != null) && shootType != ShootType.NoShoot)
        {
            mover.SetIsStopped(true);
        }
        else
        {
            mover.SetIsStopped(false);
        }
        if (ds.closest != null && (msa != MSA_Type.ShootAndAimOnlyIfStoped || mover.GetIsStopped() || mover.getVelocity() == 0 || (currentOrder == null && subscribedOrders.Count == 0)) && shootType != ShootType.NoShoot && ds.closest.seenByWhom[team.num] != 0)
        {
            target = ds.closest;
        }
        else
        {
            target = null;
        }
        //Велосити остановка

        if (rb.velocity.x != 0)
        {
            if (Mathf.Abs(rb.velocity.x) < velStoper)
            {
                rb.velocity = new Vector3(0, rb.velocity.y, rb.velocity.z);
            }
            else
            {
                rb.velocity = new Vector3((Mathf.Abs(rb.velocity.x) - velStoper) * (rb.velocity.x / Mathf.Abs(rb.velocity.x)), rb.velocity.y, rb.velocity.z);
            }
        }
        if (rb.velocity.z != 0)
        {
            if (Mathf.Abs(rb.velocity.z) < velStoper)
            {
                rb.velocity = new Vector3(rb.velocity.x, rb.velocity.y, 0);
            }
            else
            {
                rb.velocity = new Vector3(rb.velocity.x, rb.velocity.y, (Mathf.Abs(rb.velocity.z) - velStoper) * (rb.velocity.z / Mathf.Abs(rb.velocity.z)));
            }
        }
        //Постараемся пополнять приказы по мере выполнения
        if (currentOrder == null && subscribedOrders.Count > 0)
        {
            currentOrder = subscribedOrders[0];
            subscribedOrders.Remove(currentOrder);
            //   meshAgent.st
        }

        //Если приказ есть
        if (currentOrder != null)
        {
            switch (currentOrder.type)
            {
            case OrderType.Move:
                if (isSelected)
                {
                    orderLine.Appear();
                }
                var act = (transform.position - currentOrder.positionTarget);
                act.y = 0;
                if (act.magnitude < mover.GetStoppingDistance())
                {
                    currentOrder.Unsubscribe(this);
                    currentOrder      = null;
                    hasProceededOrder = false;
                    FixOrderOverwrites();
                }
                else if (!hasProceededOrder)
                {
                    hasProceededOrder = true;
                    orderLine.SecondPosition(currentOrder.thing.transform);
                    mover.SetDestination(currentOrder.positionTarget);
                }
                break;

            case OrderType.UseAbility:
                if (currentAbility == null)
                {
                    currentAbility = thinker.abilities[currentOrder.abilityId];
                    switch (currentAbility.type)
                    {
                    case AbilityType.Choose:
                        currentAbility.chooseTarget = currentOrder.unitTarget;
                        break;

                    case AbilityType.SkillShot:
                        currentAbility.skillShotTarget = currentOrder.positionTarget;
                        break;
                    }
                    currentAbility.Start();
                }
                else
                {
                    if (currentAbility.canMoveOn)
                    {
                        currentAbility.canMoveOn = false;
                        hasProceededOrder        = false;
                        currentOrder.Unsubscribe(this);
                        currentAbility = null;
                        currentOrder   = null;
                        FixOrderOverwrites();
                    }
                }
                break;

            case OrderType.Attack:
                if (isSelected)
                {
                    orderLine.Appear();
                }
                if (!hasProceededOrder && currentOrder.unitTarget != null)
                {
                    orderLine.SecondPosition(currentOrder.unitTarget.transform);
                    hasProceededOrder = true;
                    shootType         = ShootType.NoShoot;
                    msa = MSA_Type.StopOnShoot;
                }
                else if (currentOrder.unitTarget == null)
                {
                    currentOrder.Unsubscribe(this);
                    currentOrder      = null;
                    hasProceededOrder = false;
                    FixOrderOverwrites();
                }
                else
                {
                    var found = false;
                    mover.SetDestination(currentOrder.unitTarget.transform.position);
                    List <Unit> arr;
                    if (team.IsMyEnemy(currentOrder.unitTarget.team))
                    {
                        arr = ds.zoneOfSight.enemiesInSight;
                    }
                    else
                    {
                        arr = ds.zoneOfSight.friendsInSight;
                    }
                    foreach (var p in arr)
                    {
                        if (p == currentOrder.unitTarget)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        shootType = orderOverwriteST;
                        target    = currentOrder.unitTarget;
                    }
                    else
                    {
                        shootType = ShootType.NoShoot;
                        target    = null;
                    }
                }
                break;

            case OrderType.Chase:
                if (isSelected)
                {
                    orderLine.Appear();
                }
                if (!hasProceededOrder)
                {
                    hasProceededOrder = true;
                    orderLine.SecondPosition(currentOrder.unitTarget.transform);
                }
                else
                {
                    mover.SetDestination(currentOrder.unitTarget.transform.position);
                }
                break;
            }
        }
    }