コード例 #1
0
 public PetIdleState(PetObject obj) : base(obj)
 {
     m_OwnerTarget    = pet.owner.GetComponent <PlayerTarget>();
     m_OwnerDamagable = pet.owner.GetComponent <DamagableObject>();
     m_PetWeapon      = pet.GetComponent <PetWeapon>();
     m_PetTarget      = pet.GetComponent <PlayerTarget>();
 }
コード例 #2
0
    private void UpdateTargetedPlayer()
    {
        RaycastHit hit;

        // Find nearest visible player.
        targetedPlayer = null;
        float targetedPlayerDistance2 = float.PositiveInfinity;

        foreach (PlayerTarget player in PlayerTarget.Players)
        {
            Vector3 relativePlayerPosition = player.transform.position - transform.position;
            float   playerDistance2        = relativePlayerPosition.sqrMagnitude;

            if (playerDistance2 >= targetedPlayerDistance2)
            {
                continue;
            }

            if (Physics.Raycast(transform.position, relativePlayerPosition, out hit, Mathf.Sqrt(playerDistance2), SensorLevelLayers))
            {
                continue;
            }

            targetedPlayer          = player;
            targetedPlayerDistance2 = playerDistance2;
            Rigidbody rbody = player.GetComponent <Rigidbody>();
            foreach (AITargetObserver observer in observers)
            {
                observer.Target = rbody;
            }
        }
    }
コード例 #3
0
ファイル: Enemy.cs プロジェクト: antonykidis/Dodge
        private void ChangePlayerTarget()
        {
            if (Board.Player == null)
            {
                return;
            }

            switch (_playerTarget)
            {
            case PlayerTarget.Top:
                _playerTarget = PlayerTarget.Right;
                break;

            case PlayerTarget.Right:
                _playerTarget = PlayerTarget.Bottom;
                break;

            case PlayerTarget.Bottom:
                _playerTarget = PlayerTarget.Left;
                break;

            case PlayerTarget.Left:
                _playerTarget = PlayerTarget.Top;
                break;

            default:
                break;
            }
        }
コード例 #4
0
 public void UpdatePlayerTargetPosition(GameObject targetObject)
 {
     ClearTargetPosition();
     Target = new PlayerTarget(targetObject);
     ToggleEnemyTargetVisibility(true);
     UpdateAnimationParameters();
 }
コード例 #5
0
 public LootState(Stack <IBotState> botStates, Player player,
                  KeyBindSender keyBindSender)
 {
     _botStates     = botStates;
     _player        = player;
     _keyBindSender = keyBindSender;
     _target        = player.Target;
 }
コード例 #6
0
    public void Attack()
    {
        PlayerTarget target = player.transform.GetComponent <PlayerTarget>();

        if (target != null)
        {
            target.PlayerDamage(10);
        }
    }
コード例 #7
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        PlayerTarget player = collision.gameObject.GetComponent <PlayerTarget>();

        if (player != null)
        {
            CheckOpen(player);
        }
    }
コード例 #8
0
ファイル: PetManager.cs プロジェクト: OlegGelezcov/neb
 public override void Start()
 {
     if (!m_StartCalled) {
         m_StartCalled = true;
         base.Start();
         m_Character = GetComponent<PlayerCharacterObject>();
         m_Player = GetComponent<MmoActor>();
         m_PlayerTarget = GetComponent<PlayerTarget>();
         m_Bonuses = GetComponent<PlayerBonuses>();
     }
 }
コード例 #9
0
    // Update is called once per frame
    void Update()
    {
        PlayerTarget playerTarget = player.GetComponent <PlayerTarget>();

        if (playerTarget.IsDead == true)
        {
            playerTarget.IsDead       = false;
            player.transform.position = SpawnPoint.position;
            player.SetActive(true);
        }
    }
コード例 #10
0
ファイル: PlayerShoot.cs プロジェクト: Yaruno292/networkFps
    void Shoot()
    {
        StartCoroutine(TBB(currentWeaponTbb));
        particles[currentWeapon].Play();
        audioSource.clip = ShotSounds[currentWeapon];
        audioSource.Play();


        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
        {
            target       = hit.transform.GetComponent <Target>();
            playerTarget = hit.transform.GetComponent <PlayerTarget>();

            if (target != null)
            {
                target.TakeDmg(damage);
                DealDmgObj();
                Debug.Log("takes dmg");
            }

            if (playerTarget != null)
            {
                playerTarget.TakeDmg(damage);
                DealDmgPlayer();
                Debug.Log("player hit");
            }

            if (hit.rigidbody != null)
            {
                hit.rigidbody.AddForce(-hit.normal * impactForce);
                KnockBack();
                Debug.Log("adds knockback");
            }
        }

        Debug.Log("shoots");
        GameObject impactObj = Instantiate(impactParticle, hit.point, Quaternion.LookRotation(hit.normal));

        Destroy(impactObj, 2f);
        NetworkServer.Spawn(impactObj);
        if (t < 0)
        {
            NetworkServer.Destroy(impactObj);
            t = 2f;
        }
        else
        {
            t -= Time.deltaTime;
        }

        weapons[currentWeapon].GetComponent <Animation>().Play();
    }
コード例 #11
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (!collision.CompareTag("Enemy") && !collision.CompareTag("Projectile") && !collision.CompareTag("Powerup"))
        {
            PlayerTarget target = collision.transform.GetComponent <PlayerTarget>();

            if (target != null)
            {
                target.TakeDamage(damage);
            }

            Destroy(this.gameObject);
        }
    }
コード例 #12
0
ファイル: ImpactWithPlayer.cs プロジェクト: RikuDude/Space101
    private void damageAndPushPlayer(Collider2D collider)
    {
        if (collider.CompareTag("Player"))
        {
            PlayerTarget target = collider.transform.GetComponent <PlayerTarget>();

            if (target != null)
            {
                target.TakeDamage(impactDamage);
                // pushing the player away from the enemy
                collider.transform.GetComponent <Rigidbody2D>().AddForce(calculateNormalizedCollisionVector(collider.transform) * impactForce);
            }
        }
    }
コード例 #13
0
        public override void Start()
        {
            base.Start();
            mWeapon    = RequireComponent <BaseWeapon>();
            mMessage   = RequireComponent <MmoMessageComponent>();
            mCharacter = RequireComponent <CharacterObject>();
            mTarget    = RequireComponent <PlayerTarget>();
            mMovable   = GetComponent <MovableObject>();
            m_Skills   = GetComponent <PlayerSkills>();
            m_Bonuses  = GetComponent <PlayerBonuses>();

            mChestLiveDuration = nebulaObject.world.Resource().ServerInputs.GetValue <float>("chest_life");
            //log.InfoFormat("chest life = {0}", mChestLiveDuration);
            mShotTimer = m_ShotCooldown;

            mDead = false;

            combatAIType = aiType as CombatAIType;
            if (combatAIType == null)
            {
                log.Error("CombatBasseAI must have CombatAIType, but not simple AIType");
            }
            mShipWeapon = GetComponent <ShipWeapon>();
            if (Rand.Int() % 2 == 0)
            {
                mMovNearTargetType = MovingNearTarget.Circle;
            }
            else
            {
                mMovNearTargetType = MovingNearTarget.LIne;
            }
            mStartPosition = nebulaObject.transform.position;

#if USE_SKILLS
            //--------------------------TESTING------------------------------------
            var ship = GetComponent <BaseShip>();
            if (ship)
            {
                string sSkill = skills[Rand.Int(skills.Count - 1)];
                ship.shipModel.Slot(ShipModelSlotType.CB).Module.SetSkill(SkillExecutor.SkilIDFromHexString(sSkill));
                mSkills = GetComponent <PlayerSkills>();
                mSkills.UpdateSkills(ship.shipModel);
            }
            //--------------------------------------------------------------------
#endif

            mBotObject = GetComponent <BotObject>();
            SetupSkills();
        }
コード例 #14
0
ファイル: Health.cs プロジェクト: RikuDude/Space101
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            PlayerTarget target = collision.transform.GetComponent <PlayerTarget>();

            if (target != null)
            {
                target.TakeHealing(healing);
            }

            Debug.Log("Health collided with something!");

            Destroy(this.gameObject);
        }
    }
コード例 #15
0
        public override void Start()
        {
            base.Start();
            m_Pet     = GetComponent <PetObject>();
            m_Target  = GetComponent <PlayerTarget>();
            m_Message = GetComponent <MmoMessageComponent>();
            m_Race    = GetComponent <RaceableObject>();

            if (m_Pet)
            {
                if (m_Pet.info != null)
                {
                    m_Timer = m_Pet.info.Cooldown(nebulaObject.resource.petParameters.cooldown);
                }
            }
        }
コード例 #16
0
ファイル: NadeExplode.cs プロジェクト: Yaruno292/networkFps
    private void CmdExplode()
    {
        GameObject expl = Instantiate(explosion, transform.position, transform.rotation);

        NetworkServer.Spawn(expl);
        Collider[] collidersToDestroy = Physics.OverlapSphere(transform.position, raduis);

        foreach (Collider nearObj in collidersToDestroy)
        {
            Target       target       = nearObj.GetComponent <Target>();
            PlayerTarget playerTarget = nearObj.GetComponent <PlayerTarget>();
            if (target != null)
            {
                target.TakeDmg(damage);
            }
            if (playerTarget != null)
            {
                playerTarget.TakeDmg(damage);
            }
        }

        foreach (Collider nearTerrain in collidersToDestroy)
        {
            Terrain terrain = nearTerrain.GetComponent <Terrain>();
            if (terrain != null)
            {
                terrainD.DestroyTerrain();
            }
            else
            {
                NetworkServer.Destroy(gameObject);
                Destroy(gameObject);
            }
        }


        Collider[] collidersToMove = Physics.OverlapSphere(transform.position, raduis);

        foreach (Collider nearObj in collidersToMove)
        {
            Rigidbody rb = nearObj.GetComponent <Rigidbody>();
            if (rb != null)
            {
                rb.AddExplosionForce(force, transform.position, raduis);
            }
        }
    }
コード例 #17
0
ファイル: Enemy.cs プロジェクト: antonykidis/Dodge
        private void LoadFromXML(XElement xEntity)
        {
            LifeCount    = (int)xEntity.Attribute("Life");
            _stepSize    = (int)xEntity.Attribute("StepSize");
            _movePattern = xEntity.Attribute("MovePattern") != null ?
                           (MovePattern)Enum.Parse(typeof(MovePattern), xEntity.Attribute("MovePattern").Value) : _movePattern;
            int centerRow = xEntity.Attribute("CenterRow") != null?
                            int.Parse(xEntity.Attribute("CenterRow").Value) : -1;

            int centerCol = xEntity.Attribute("CenterCol") != null?
                            int.Parse(xEntity.Attribute("CenterCol").Value) : -1;

            if (centerRow != -1 && centerCol != -1)
            {
                _circleCenter = new Position(centerRow, centerCol);
            }
            _isClockwise = xEntity.Attribute("_isClockwise") != null?
                           bool.Parse(xEntity.Attribute("_isClockwise").Value) : _isClockwise;

            _movePace = xEntity.Attribute("MovePace") != null ?
                        (MovePace)Enum.Parse(typeof(MovePace), xEntity.Attribute("MovePace").Value) : _movePace;
            StepInterval = xEntity.Attribute("StepInterval") != null?
                           int.Parse(xEntity.Attribute("StepInterval").Value) : StepInterval;

            _playerTarget = xEntity.Attribute("PlayerTarget") != null ?
                            (PlayerTarget)Enum.Parse(typeof(PlayerTarget), xEntity.Attribute("PlayerTarget").Value) : _playerTarget;
            _stepQuantum = xEntity.Attribute("StepQuantum") != null?
                           int.Parse(xEntity.Attribute("StepQuantum").Value) : _stepQuantum;

            _stepQuantumCounter = xEntity.Attribute("StepQuantumCounter") != null?
                                  int.Parse(xEntity.Attribute("StepQuantumCounter").Value) : _stepQuantumCounter;

            XElement xDirection = xEntity.Element("MoveDirection");

            if (xDirection != null)
            {
                _moveDirection.Up    = (bool)xDirection.Attribute("Up");
                _moveDirection.Down  = (bool)xDirection.Attribute("Down");
                _moveDirection.Left  = (bool)xDirection.Attribute("Left");
                _moveDirection.Right = (bool)xDirection.Attribute("Right");
            }
            if (xEntity.Attribute("ImageURI") != null)
            {
                Image.Source = new BitmapImage(new Uri(xEntity.Attribute("ImageURI").Value));
            }
        }
コード例 #18
0
        public void Process(byte[] buffer, IConnection connection)
        {
            var pData      = Authentication.Players[connection.Index];
            var msg        = new ByteBuffer(buffer);
            var target     = msg.ReadInt32();
            var targetType = msg.ReadInt32();

            if (Enum.IsDefined(typeof(TargetType), targetType))
            {
                var changeTarget = new PlayerTarget()
                {
                    Player = Authentication.Players[connection.Index]
                };

                changeTarget.ChangeTarget(target, (TargetType)targetType);
            }
        }
コード例 #19
0
    // Use this for initialization
    void Start()
    {
        UpdateTarget();
        updatingTarget = false;
        playerTarget   = GameObject.FindWithTag("PlayerTarget").GetComponent <PlayerTarget>();
        damageOverTime = DAMAGE_OVER_TIME;
        fireRate       = FIRE_RATE;
        laserSound     = true;
        am             = GameObject.FindGameObjectWithTag("gamemanager").GetComponent <AudioManager>();
        slowReduction  = slowReduction / (damageMultiplier * 1.25f);

        if (moneyTurret)
        {
            StartCoroutine(GivePlayerMoney());
        }

        nodeIsPressed    = false;
        currentFirePoint = 0;
    }
コード例 #20
0
 void CheckOpen(PlayerTarget player)
 {
     if (redDoor && player.redTarget)
     {
         doorBlock.SetActive(false);
         player.redTarget = false;
         AudioManager.GetInstance().Play("Door");
     }
     else if (blueDoor && player.blueTarget)
     {
         doorBlock.SetActive(false);
         player.blueTarget = false;
         AudioManager.GetInstance().Play("Door");
     }
     else if (yellowDoor && player.yellowTarget)
     {
         doorBlock.SetActive(false);
         player.yellowTarget = false;
         AudioManager.GetInstance().Play("Door");
     }
 }
コード例 #21
0
ファイル: Enemy.cs プロジェクト: antonykidis/Dodge
        public Enemy(int id, Board board, Position position = null, XElement xEntity = null)
            : base(id, board, EntityType.Enemy, position)
        {
            InitTimer();

            if (xEntity != null)
            {
                LoadFromXML(xEntity);
            }
            else
            {
                InitMovePattern();
                InitMovePace();
                InitMoveDirection();

                _stepSize           = DEFAULT_STEP_SIZE;
                _playerTarget       = PlayerTarget.Top;
                LifeCount           = DEFAULT_LIFE_COUNT;
                CurrentStepInterval = StepInterval = BEGINNER_STEP_INTERVAL;
            }
        }
コード例 #22
0
        public override void Start()
        {
            if (!m_StartCalled)
            {
                m_StartCalled   = true;
                mShip           = RequireComponent <PlayerShip>();
                mTarget         = RequireComponent <PlayerTarget>();
                mCharacter      = RequireComponent <PlayerCharacterObject>();
                mAI             = RequireComponent <AIState>();
                mRace           = RequireComponent <RaceableObject>();
                mMessage        = RequireComponent <MmoMessageComponent>();
                mDamagable      = RequireComponent <ShipBasedDamagableObject>();
                mWeapon         = RequireComponent <ShipWeapon>();
                mSkills         = RequireComponent <PlayerSkills>();
                mBonuses        = RequireComponent <PlayerBonuses>();
                mPassiveBonuses = GetComponent <PassiveBonusesComponent>();

                mCharacter.SetCharacterId((string)nebulaObject.Tag((byte)PlayerTags.CharacterId));
                mCharacter.SetCharacterName((string)nebulaObject.Tag((byte)PlayerTags.Name));
                printPropertiesTimer = printPropertiesInterval;

                if (application.serverActors.ContainsKey(nebulaObject.Id))
                {
                    MmoActor old;
                    if (application.serverActors.TryRemove(nebulaObject.Id, out old))
                    {
                        log.Info("successfully remove actor before replacing with new [red]");
                    }
                }
                if (application.serverActors.TryAdd(nebulaObject.Id, this))
                {
                    log.Info("successfully added actor to server actors [red]");
                }

                //create chest on killing when player die
                mDamagable.SetCreateChestOnKilling(true);
                mDamagable.SetIgnoreDamageInterval(30);
                mDamagable.SetIgnoreDamageAtStart(true);
            }
        }
コード例 #23
0
    public PlayerTarget GetClosestPlayerToDistance(Vector3 argInMyPosition, float argInDistance)
    {
        PlayerTarget bestTargetNonInv   = null;
        PlayerTarget bestTargetInv      = null;
        float        closestDistanceSqr = Mathf.Infinity;

        //Vector3 currentPosition = argInMyPosition;
        foreach (PlayerTarget potentialTarget in playerTargets)
        {
            if (potentialTarget.isInvulnerable == false)
            {
                float distance = Vector3.Distance(((Component)potentialTarget).gameObject.transform.position, argInMyPosition);
                float dist     = Mathf.Abs(distance - argInDistance);

                if (dist < closestDistanceSqr)
                {
                    closestDistanceSqr = dist;
                    bestTargetNonInv   = potentialTarget;
                }
            }
            else
            {
                float distance = Vector3.Distance(((Component)potentialTarget).gameObject.transform.position, argInMyPosition);
                float dist     = Mathf.Abs(distance - argInDistance);
                if (dist < closestDistanceSqr)
                {
                    closestDistanceSqr = dist;
                    bestTargetInv      = potentialTarget;
                }
            }
        }

        if (bestTargetNonInv != null)
        {
            return(bestTargetNonInv);
        }

        return(bestTargetInv);
    }
コード例 #24
0
    public PlayerTarget GetPlayerClosestToItsObjective(PlayerTarget argInCaller)
    {
        PlayerTarget bestTargetNonInv   = null;
        PlayerTarget bestTargetInv      = null;
        float        closestDistanceSqr = Mathf.Infinity;

        foreach (PlayerTarget potentialTarget in playerTargets)
        {
            if (potentialTarget != argInCaller)
            {
                if (potentialTarget.isInvulnerable == false)
                {
                    float dist = Vector3.Distance(((Component)potentialTarget).gameObject.transform.position, potentialTarget.globalObjective);

                    if (dist < closestDistanceSqr)
                    {
                        closestDistanceSqr = dist;
                        bestTargetNonInv   = potentialTarget;
                    }
                }
                else
                {
                    float dist = Vector3.Distance(((Component)potentialTarget).gameObject.transform.position, potentialTarget.globalObjective);
                    if (dist < closestDistanceSqr)
                    {
                        closestDistanceSqr = dist;
                        bestTargetInv      = potentialTarget;
                    }
                }
            }
        }

        if (bestTargetNonInv != null)
        {
            return(bestTargetNonInv);
        }

        return(bestTargetInv);
    }
コード例 #25
0
ファイル: DodgeBallScript.cs プロジェクト: CoolTaff12/K1ller
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.tag == "Player")
        {
			playerInfo = col.gameObject.GetComponent<PlayerTarget>();
			if (playerInfo.teamNumber != thrownByTeam) {
				playerInfo.health -= 1;
			}

        }
        if (col.gameObject.tag == "ForceField")
        {
           GameObject Sparked = (GameObject) Instantiate(Sparks, transform.position, Quaternion.identity);
            Destroy(Sparked, 3f);
        }
        else if (col.gameObject.tag != "Player" || col.gameObject.tag != "ForceField")
        {
            int SelectSoundFile = Random.Range(0, 4);
            PlaySound(SelectSoundFile);
        }

    }
コード例 #26
0
    public PlayerTarget GetClosestPlayerTarget(Vector3 argInMyPosition)
    {
        PlayerTarget bestTargetNonInv   = null;
        PlayerTarget bestTargetInv      = null;
        float        closestDistanceSqr = Mathf.Infinity;
        Vector3      currentPosition    = argInMyPosition;

        foreach (PlayerTarget potentialTarget in playerTargets)
        {
            if (potentialTarget.isInvulnerable == false)
            {
                Vector3 directionToTarget = ((Component)potentialTarget).gameObject.transform.position - currentPosition;
                float   dSqrToTarget      = directionToTarget.sqrMagnitude;
                if (dSqrToTarget < closestDistanceSqr)
                {
                    closestDistanceSqr = dSqrToTarget;
                    bestTargetNonInv   = potentialTarget;
                }
            }
            else
            {
                Vector3 directionToTarget = ((Component)potentialTarget).gameObject.transform.position - currentPosition;
                float   dSqrToTarget      = directionToTarget.sqrMagnitude;
                if (dSqrToTarget < closestDistanceSqr)
                {
                    closestDistanceSqr = dSqrToTarget;
                    bestTargetInv      = potentialTarget;
                }
            }
        }

        if (bestTargetNonInv != null)
        {
            return(bestTargetNonInv);
        }

        return(bestTargetInv);
    }
コード例 #27
0
    void Shoot()
    {
        Debug.Log("Fire!");
        _anim.SetBool("Fire", true);

        if (_nextTimeToFire <= Time.time)
        {
            FindObjectOfType <AudioManager>().Play("Rifle");

            _nextTimeToFire = Time.time + 1 / fireRate;
            RaycastHit hit;
            if (Physics.Raycast(gunTip.position, gunTip.forward, out hit, Mathf.Infinity))
            {
                PlayerTarget playerTarget = hit.transform.gameObject.GetComponent <PlayerTarget>();
                AITarget     aiTarget     = hit.transform.gameObject.GetComponent <AITarget>();

                if (playerTarget != null)
                {
                    playerTarget.Hurt(damage, this.gameObject.transform);
                }

                if (aiTarget != null)
                {
                    SphereCollider  aiHead = hit.transform.gameObject.GetComponent <SphereCollider>();
                    CapsuleCollider aiBody = hit.transform.gameObject.GetComponent <CapsuleCollider>();
                    if (aiHead != null && hit.collider == aiHead)
                    {
                        aiTarget.HeadShot();
                        GameObject electricHit = Instantiate(aiTarget.electricHitPrefab, hit.point, Quaternion.identity);
                    }
                    else if (aiBody != null && hit.collider == aiBody)
                    {
                        aiTarget.TakeDamage(damage);
                    }
                }
            }
        }
    }
コード例 #28
0
    private void UpdateTargetedPlayer()
    {
        RaycastHit hit;

        // Find nearest visible player.
        targetedPlayer = null;
        float targetedPlayerDistance2 = float.PositiveInfinity;
        foreach (PlayerTarget player in PlayerTarget.Players)
        {
            Vector3 relativePlayerPosition = player.transform.position - transform.position;
            float playerDistance2 = relativePlayerPosition.sqrMagnitude;

            if (playerDistance2 >= targetedPlayerDistance2)
                continue;

            if (Physics.Raycast(transform.position, relativePlayerPosition, out hit, Mathf.Sqrt(playerDistance2), TrackingLevelLayers))
                continue;

            targetedPlayer = player;
            targetedPlayerDistance2 = playerDistance2;
            tracking.TrackedTarget = player.GetComponent<Rigidbody>();
        }
    }
コード例 #29
0
 public void AddPlayerTarget(PlayerTarget argInPlayerTarget)
 {
     playerTargets.Add(argInPlayerTarget);
 }
コード例 #30
0
ファイル: TargetSystem.cs プロジェクト: amansg57/ScarletMoon
 public void AddPlayerTarget(PlayerTarget pt)
 {
     playerTargets.Add(pt);
 }
コード例 #31
0
 public Effect(PlayerTarget argInPlayer, EffectHandler argInEffectHandler)
 {
     MyEffectHandler = argInEffectHandler;
     player          = argInPlayer;
 }
コード例 #32
0
 public void RemovePlayerTarget(PlayerTarget argInPlayerTarget)
 {
     playerTargets.RemoveAll(x => x == argInPlayerTarget);
 }