Esempio n. 1
0
    // Use this for initialization
    public override bool Attack(Dirs dir)
    {
        // Shoot out a ray to check for a collision with the level layer.
        RaycastHit2D hit = Physics2D.Raycast(transform.position,                                // origin
                                             GridMovement.DirTable[dir],                        // Lookup table (direction)!
                                             1f,                                                // Only 1 unit Grid
                                             LayerMask.GetMask("Enemies"));                     // Only on this layer

        // If a collider exists, we found an enemy
        if (hit.collider != null)
        {
            // Debug.Log("FOUND AN ENEMY!!!");
            EnemyComponent ec = hit.collider.gameObject.GetComponent <EnemyComponent>();
            if (ec != null)
            {
                ec.Hit(damage);

                // Direction
                Vector2 vdir = GridMovement.DirTable[dir];

                // Make an arrow.
                GameObject swipe = Instantiate(Resources.Load("DaggerSwipe") as GameObject);

                // Set potision
                Transform trans = swipe.transform;
                trans.position = transform.position + (Vector3)vdir;

                // Rotate
                float angle = Mathf.Atan2(vdir.y, vdir.x) * Mathf.Rad2Deg;
                trans.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
            }
        }
        return(hit.collider != null);
    }
Esempio n. 2
0
 public TextSystem(DungeonCrawlerGame game)
 {
     _game = game;
     _actorTextComponent = _game.ActorTextComponent;
     _playerComponent = _game.PlayerComponent;
     _enemyComponent = _game.EnemyComponent;
 }
Esempio n. 3
0
    //Получаем вектор в сторону ближайшего врага
    public Vector3 GetNearestTarget(Vector3 origin)
    {
        EnemyComponent nearestEnemy = null;
        float          minDistance  = float.MaxValue;

        foreach (EnemyComponent enemy in enemyList)
        {
            float distance = (enemy.transform.position - origin).sqrMagnitude;

            if (distance < minDistance)
            {
                nearestEnemy = enemy;
                minDistance  = distance;
            }
        }

        if (nearestEnemy == null)
        {
            return(Vector3.zero);
        }
        else
        {
            return(nearestEnemy.transform.position);
        }
    }
Esempio n. 4
0
        void Shoot()
        {
            ammo = ammo - 1;
            int        st     = -1 * (ammo - temp);
            int        stored = st;
            RaycastHit hit;

            if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
            {
                EnemyComponent target = hit.transform.GetComponent <EnemyComponent>();
                if (target != null)
                {
                    Instantiate(ps, hit.point, Quaternion.LookRotation(hit.normal));
                    Instantiate(ps2, hit.point, Quaternion.LookRotation(hit.normal));
                    target.TakeDamage(damage);
                }
                else if (target == null)
                {
                    Instantiate(ps2, hit.point, Quaternion.LookRotation(hit.normal));
                }
                if (hit.rigidbody != null)
                {
                    hit.rigidbody.AddForce(-hit.normal * iforce);
                }
                temp2 = stored;
            }
        }
    public void Update()
    {
        ListReadOnly <EnemyComponent> enemyComponents = entityDatabase.QueryTypes <EnemyComponent>();

        if (enemyComponents.Count == 0)
        {
            return;
        }

        Entity    playerEntity    = entityDatabase.QueryEntity <PlayerComponent>();
        Transform playerTransform = playerEntity.GetComponent <TransformComponent>().transform;

        var enumerator = enemyComponents.GetEnumerator();

        while (enumerator.MoveNext())
        {
            EnemyComponent enemyComponent = enumerator.Current;

            if (enemyComponent.currentHealth > 0 &&
                !playerEntity.HasTag(Tag.Dead))
            {
                enemyComponent.nav.SetDestination(playerTransform.position);
            }
            else
            {
                enemyComponent.nav.enabled = false;
            }
        }
    }
Esempio n. 6
0
    public void OnKillEnemy(EnemyComponent enemy)
    {
        var score = GetEnemyKillScore(enemy.enemyType);

        Player.Main.WaveScore  += score;
        Player.Main.TotalScore += score;
    }
Esempio n. 7
0
    public override void Initialize(Transform[] objects)
    {
        // list because I don't know size here
        List <Filter> tmpFilters = new List <Filter>();
        int           index      = 0;

        for (int i = 0; i < objects.Length; i++)
        {
            // check performance
            EnemyComponent  ec = objects[i].GetComponent <EnemyComponent>();
            CombatComponent cc = objects[i].GetComponent <CombatComponent>();
            HealthComponent hc = objects[i].GetComponent <HealthComponent>();

            if (cc && hc)
            {
                tmpFilters.Add(new Filter(index, objects[i].gameObject, ec, cc, hc));
            }
        }

        filters = tmpFilters.ToArray();

        environmentComponent   = GetComponentInChildren <EnvironmentComponent>();
        transportableComponent = GetComponentInChildren <CartComponent>();
        inputComponent         = GetComponentInChildren <InputComponent>();
    }
    public void Update()
    {
        ListReadOnly <EnemyComponent> enemyComponents = entityDatabase.QueryTypes <EnemyComponent>();

        if (enemyComponents.Count == 0)
        {
            return;
        }

        Entity     playerEntity = entityDatabase.QueryEntity <PlayerComponent>();
        GameObject playerObject = playerEntity.GetComponent <TransformComponent>().transform.gameObject;

        var enumerator = enemyComponents.GetEnumerator();

        while (enumerator.MoveNext())
        {
            EnemyComponent enemyComponent = enumerator.Current;
            enemyComponent.attackTimer += Time.deltaTime;

            if (enemyComponent.attackTimer >= enemyComponent.enemyDO.timeBetweenAttacks &&
                enemyComponent.trigger.isColliding(playerObject) &&
                enemyComponent.currentHealth > 0)
            {
                Attack(enemyComponent, playerEntity);
            }

            if (playerEntity.HasTag(Tag.Dead))
            {
                enemyComponent.anim.SetTrigger("PlayerDead");
            }
        }
    }
Esempio n. 9
0
    private void UpdateTarget()
    {
        GameObject[] enemies          = GameObject.FindGameObjectsWithTag(m_EnemyTag);
        float        shortestDistance = Mathf.Infinity;
        GameObject   nearestEnemy     = null;

        foreach (GameObject enemy in enemies)
        {
            float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);
            if (distanceToEnemy < shortestDistance)
            {
                shortestDistance = distanceToEnemy;
                nearestEnemy     = enemy;
            }
        }

        if (nearestEnemy != null && shortestDistance <= m_Range)
        {
            m_Target = nearestEnemy.transform;
            m_Enemy  = nearestEnemy.GetComponent <EnemyComponent> ();
        }
        else
        {
            m_Target = null;
        }
    }
Esempio n. 10
0
        private void CreateEnemy(Loader loader, Vector3 position)
        {
            _currentEnemyCount++;
            var file = @"Resources\Models\wolf.fbx";
            var wolf = loader.LoadGameObjectFromFile(file, position, Vector3.Zero);

            wolf.Tag       = "enemy";
            wolf.Collision = new BoxCollision(1.5f, 0.7f);
            wolf.AddComponent(new ColliderComponent());
            wolf.AddScript(new ColliderScript());
            var voice_1 = new SharpAudioVoice(_audioDevice, @"Resources\Audio\Лай волков.wav");
            var voice_2 = new SharpAudioVoice(_audioDevice, @"Resources\Audio\Серия укусов.wav");

            wolf.AddComponent(new ReloadComponent(2.5f));
            wolf.AddScript(new ReloadScript());
            var wolfComponent = new EnemyComponent(3, 8.0f);

            wolfComponent.OnEnemyDeath += UpdateWolfCount;
            wolf.AddComponent(wolfComponent);
            wolf.AddScript(new Enemy(voice_1, voice_2, _player, 20.0f, 10));
            file = @"Resources\Models\wolfHead.fbx";
            var head = loader.LoadGameObjectFromFile(file, new Vector3(0.0f, 0.23f, -0.48f), Vector3.Zero);

            wolf.AddChild(head);
            AddGameObject(wolf);
        }
    public void Update()
    {
        ListReadOnly <EnemyDamageComponent> enemyDamageComponent = entityDatabase.QueryTypes <EnemyDamageComponent>();

        if (enemyDamageComponent.Count == 0)
        {
            return;
        }

        for (int i = enemyDamageComponent.Count - 1; i >= 0; --i)
        {
            EnemyDamageComponent damageComponent = enemyDamageComponent[i];
            Entity entity = damageComponent.entity;

            EnemyComponent enemyComponent = entity.GetComponent <EnemyComponent>();
            enemyComponent.audioSource.Play();

            enemyComponent.hitParticles.transform.position = damageComponent.hitPoint;
            enemyComponent.hitParticles.Play();

            enemyComponent.currentHealth -= damageComponent.amount;

            if (enemyComponent.currentHealth <= 0)
            {
                Death(enemyComponent);
            }

            entity.RemoveComponent <EnemyDamageComponent>();
        }
    }
    private void Spawn(EnemySpawnerSO spawnerData)
    {
        int       spawnPointIndex = Random.Range(0, spawnerData.spawnPoints.Length);
        Transform point           = spawnerData.spawnPoints[spawnPointIndex];

        Entity         enemyEntity    = entityDatabase.CreateEntity();
        EnemyComponent enemyComponent = enemyEntity.AddComponent <EnemyComponent>();

        enemyComponent.enemyDO = spawnerData.enemyDO;

        GameObject enemyObject = GameObject.Instantiate(spawnerData.enemyDO.prefab, point.position, point.rotation);

        enemyEntity.AddComponent <TransformComponent>().transform = enemyObject.transform;

        enemyComponent.nav             = enemyObject.GetComponent <NavMeshAgent>();
        enemyComponent.audioSource     = enemyObject.GetComponent <AudioSource>();
        enemyComponent.hitParticles    = enemyObject.GetComponentInChildren <ParticleSystem>();
        enemyComponent.capsuleCollider = enemyObject.GetComponent <CapsuleCollider>();
        enemyComponent.rigidBody       = enemyObject.GetComponent <Rigidbody>();
        enemyComponent.anim            = enemyObject.GetComponent <Animator>();
        enemyComponent.trigger         = enemyObject.GetComponent <TriggerBehaviour>();
        enemyComponent.currentHealth   = spawnerData.enemyDO.startingHealth;

        entityDatabase.QueryType <ColliderComponentMap>().Add(enemyObject, enemyEntity);
    }
 // Start is called before the first frame update
 void Start()
 {
     pool           = GetComponent <PoolManagerObjects>();
     enemyComponent = GetComponent <EnemyComponent>();
     time           = 60 / dpm;
     currentTime    = time;
 }
Esempio n. 14
0
 public TextSystem(DungeonCrawlerGame game)
 {
     _game = game;
     _actorTextComponent = _game.ActorTextComponent;
     _playerComponent    = _game.PlayerComponent;
     _enemyComponent     = _game.EnemyComponent;
 }
Esempio n. 15
0
 void OnTriggerExit(Collider col)
 {
     if (col.CompareTag(targetTag))
     {
         EnemyComponent colEnemy = col.GetComponent <EnemyComponent>();
         GameMaster.instance.ExitCombat(colEnemy);
     }
 }
Esempio n. 16
0
    /// <summary>
    /// Handle entity combat.
    /// Return true if combat resulted in defender's death
    /// and attacker is allowed to move unto that tile.
    /// </summary>
    /// <param name="attacker"></param>
    /// <param name="defender"></param>
    /// <returns></returns>
    private bool DoCombat(FighterComponent attacker, FighterComponent defender)
    {
        int attackPower = attacker.GetAttackPower();
        // Debug.Log("Attacker attacks with power " + attackPower);
        //Debug.Log("Defender defends with power " + defender.GetDefensePower());
        //if (attacker.thisEntity.isPlayer == true)
        //{
        //    MessageLog_Manager.NewMessage("You attack the " + defender.thisEntity.Name + " with " + attackPower + " attack!", Color.red);
        //}
        int damage = attackPower - defender.GetDefensePower();

        //Debug.Log("After defense mitigation... damage is " + damage);

        if (damage > 0)
        {
            if (defender.thisEntity.isPlayer == true)
            {
                cameraShaker.AddTrauma(5.2f, 2.8f);
                MessageLog_Manager.NewMessage(attacker.thisEntity.Name + " hits you for " + damage.ToString() + "!", Color.white);
            }
            else
            {
                MessageLog_Manager.NewMessage("You hit the " + defender.thisEntity.Name + " for " + damage.ToString() + "!", Color.red);
            }
        }
        else
        {
            if (attacker.thisEntity.isPlayer == true)
            {
                MessageLog_Manager.NewMessage(defender.thisEntity.Name + "'s defense absorb your attack!", Color.white);
            }
            else
            {
                MessageLog_Manager.NewMessage("Your defenses absorb the attack!", Color.white);
            }
        }

        bool result = defender.ReceiveDamage(damage);

        if (result == true)
        {
            if (attacker.thisEntity.isPlayer == true)
            {
                MessageLog_Manager.NewMessage(defender.thisEntity.Name + " DIES!", Color.red);
                // Gain xp for kill
                XPComponent    xPComponent = (XPComponent)attacker.thisEntity.GetEntityComponent(ComponentID.XP);
                EnemyComponent enemy       = (EnemyComponent)defender.thisEntity.GetEntityComponent(ComponentID.AI);
                XPSystem.instance.DoXPGainAction(xPComponent.xpData, enemy.enemyLevel);
            }
            else
            {
                MessageLog_Manager.NewMessage(attacker.thisEntity.Name + " KILLS YOU!", Color.red);
            }
        }

        return(result);
    }
Esempio n. 17
0
 public void ExitCombat(EnemyComponent enemy)
 {
     involvedInCombat.Remove(enemy);
     print("combat: " + involvedInCombat.Count);
     if (involvedInCombat.Count == 0)
     {
         battleState = BattleState.Peace;
     }
 }
    private void Damage(Transform enemy)
    {
        EnemyComponent e = enemy.GetComponent <EnemyComponent>();

        if (e != null)
        {
            e.TakeDamage(m_Damage);
        }
    }
Esempio n. 19
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        EnemyComponent enemy = collider.gameObject.GetComponent <EnemyComponent>();

        if (enemy != null)
        {
            enemy.GetComponent <ShipComponent>().Damage(damage);
            poolableObject.ReturnToPool();
        }
    }
    private void Attack(EnemyComponent enemyComponent, Entity playerEntity)
    {
        enemyComponent.attackTimer = 0f;

        if (!playerEntity.HasTag(Tag.Dead) &&
            !playerEntity.GetComponent <PlayerDamageComponent>())
        {
            playerEntity.AddComponent <PlayerDamageComponent>().amount = enemyComponent.enemyDO.attackDamage;
        }
    }
Esempio n. 21
0
        public void Apply(IEntity entity)
        {
            var enemyComponent = new EnemyComponent();

            enemyComponent.Health.Value = 3;
            enemyComponent.EnemyType    = GetRandomEnemyType();
            enemyComponent.EnemyPower   = enemyComponent.EnemyType == EnemyTypes.Regular ? 10 : 20;
            entity.AddComponents(enemyComponent, new ViewComponent(),
                                 new MovementComponent(), new RandomlyPlacedComponent());
        }
    private void ClearData()
    {
        mechanicInPlay          = false;
        currentMechanicLifetime = 2.0f;
        GameObject.Destroy(instantiatedCriticalEffectUI);
        instantiatedCriticalEffectOuterRing = null;
        instantiatedCriticalEffectInnerRing = null;

        targetComponent = null;
    }
Esempio n. 23
0
    void Awake()
    {
        Assert.IsNotNull(this.arrowPrefab);
        Assert.IsNotNull(this.archerFireCheckerComponent);

        this.enemyComponent    = this.GetComponent <EnemyComponent>();
        this.archerFireChecker = this.archerFireCheckerComponent as IArcherFireChecker;
        // Will be null if archerFireCheckerComponent does not implement IArcherFireChecker:
        Assert.IsNotNull(this.archerFireChecker);
    }
    protected void Init()
    {
        // NOTE(clark, 2/8/2017): Added ec. Calling GetComponent takes a fair bit of time
        ec = GetComponent <EnemyComponent>();
        GridUpdateSubscriber   gus = GetComponent <GridUpdateSubscriber>();
        GridMovementSubscriber gms = GetComponent <GridMovementSubscriber>();

        gus.SetSubscriberMethod(new GridUpdateSubscriber.SubscriberDelegate(SubUpdate));
        gms.SetMovementMethod(new GridMovementSubscriber.MovementMethod(SubMovement));
        gms.SetAttackMethod(new GridMovementSubscriber.AttackMethod(SubAttack));
    }
Esempio n. 25
0
    public override void Initialize(Transform[] objects)
    {
        worldStateComponent = GetComponentInChildren <WorldStateComponent>();

        // list because I don't know size here
        List <Filter> tmpFilters = new List <Filter>();
        int           index      = 0;

        for (int i = 0; i < objects.Length; i++)
        {
            // check performance
            EnemyComponent  ec  = objects[i].GetComponent <EnemyComponent>();
            CombatComponent cc  = objects[i].GetComponent <CombatComponent>();
            HealthComponent hc  = objects[i].GetComponent <HealthComponent>();
            GOAPComponent   aic = objects[i].GetComponent <GOAPComponent>();

            if (cc && hc && ec && aic)
            {
                tmpFilters.Add(new Filter(index, objects[i].gameObject, ec, cc, hc, aic));

                aic.stateMachine     = new FSM();
                aic.availableActions = new HashSet <GOAPAction>();
                aic.currentActions   = new Queue <GOAPAction>();

                GOAPAction[] actions = aic.gameObject.GetComponents <GOAPAction>();
                foreach (GOAPAction action in actions)
                {
                    aic.availableActions.Add(action);
                    action.constantTarget = worldStateComponent.gameObject;
                }

                CreateIdleState(aic);
                CreateMoveToState(aic);
                CreatePerformActionState(aic);
                aic.stateMachine.pushState(aic.idleState);
            }
        }

        filters = tmpFilters.ToArray();

        planner = new GOAPPlanner();
        //currentWorldState = new HashSet<KeyValuePair<string, object>>();

        KeyValuePair <string, object> playerDmgState   = new KeyValuePair <string, object>("damagePlayer", false);
        KeyValuePair <string, object> playerStalkState = new KeyValuePair <string, object>("stalkPlayer", false);

        worldStateComponent.worldState.Add(playerLitState);
        worldStateComponent.worldState.Add(playerDmgState);
        worldStateComponent.worldState.Add(playerStalkState);

        /*currentWorldState.Add(playerLitState);
         * currentWorldState.Add(playerDmgState);
         * currentWorldState.Add(playerStalkState);*/
    }
Esempio n. 26
0
 void OnTriggerEnter(Collider col)
 {
     if (col.CompareTag("Enemy"))
     {
         EnemyComponent e = col.GetComponent <EnemyComponent>();
         if (e != null)
         {
             e.enabled = true;
         }
     }
 }
    protected override void AIDecision()
    {
        //first try to attack with default attack (since there is no skill yet)
        base.attackComponent.GenerateAttackRange(basicAttackType);

        PriorityQueue <EnemyComponent> enemyInRange = new PriorityQueue <EnemyComponent>();

        foreach (EnemyComponent en in GameMaster.instance.involvedInCombat)
        {
            if (base.attackComponent.CheckAttackInsideRange(en.currentTile))
            {
                float thisDist = currentTile.DistanceToTile(en.currentTile);
                enemyInRange.Enqueue(thisDist, en);
            }
        }

        EnemyComponent nearestEnemy = null;

        for (int i = 0; i < enemyInRange.Count; i++)
        {
            EnemyComponent currEnemy = enemyInRange.Dequeue();
            if (i == 0)
            {
                nearestEnemy = currEnemy;
            }

            if (base.attackComponent.TryAttackInsideRange(currEnemy.currentTile))             //try to attack enemy from nearest to furthest
            {
                InvokeTurnEnd();
                return;
            }
        }

        //if failed to attack all enemy, try to chase nearest enemy
        if (nearestEnemy != null && base.movementComponent.TryMoveInsideRange(nearestEnemy.currentTile, CollisionCheckEnum.All))
        {
            //char chase nearest enemy
            InvokeTurnEnd();
            UpdatePartyPosition();
            return;
        }

        //fail to follow closest enemy
        if (FollowPartyFormation())
        {
            InvokeTurnEnd();
            UpdatePartyPosition();
        }
        else
        {
            TurnEnd();
        }
    }
Esempio n. 28
0
    protected override void OnUpdate()
    {
        EnemyComponent currEnemy = null;

        BaseEnemyConfig currEnemyConfig = null;

        WaypointComponent currWaypoint = null;

        float currSpeed = 0.0f;

        float deltaTime = Time.deltaTime;

        Transform enemyTransform    = null;
        Transform waypointTransform = null;

        Vector3 dir;

        float distance = 0.0f;

        foreach (var entity in GetEntities <TEnemyGroup>())
        {
            currEnemy       = entity.mEnemy;
            currEnemyConfig = currEnemy.mConfigs;
            currWaypoint    = currEnemy.mCurrWaypoint;

            currSpeed = currEnemyConfig.mSpeed * deltaTime;

            enemyTransform    = currEnemy.CachedTransform;
            waypointTransform = currWaypoint.CachedTransform;

            /// until the enemy doesn't reach the waypoint update its position
            dir = waypointTransform.position - enemyTransform.position;

            distance = dir.magnitude;

            dir.Normalize();

            /// rotate an enemy along its move direction
            enemyTransform.rotation = Quaternion.RotateTowards(enemyTransform.rotation, QuaternionUtils.LookRotationXZ(dir), currEnemyConfig.mRotationSpeed * deltaTime);

            if (distance > 0.1f)             /// epsilon
            {
                enemyTransform.position += dir * currSpeed;

                continue;
            }

            if (currWaypoint.mNextWaypoint != null)
            {
                currEnemy.mCurrWaypoint = currWaypoint.mNextWaypoint;
            }
        }
    }
Esempio n. 29
0
    public override void Tick(float deltaTime)
    {
        for (int i = 0; i < filters.Length; i++)
        {
            // cache variables
            Filter filter = filters[i];

            EnemyComponent  enemyComp  = filter.enemyComponent;
            CombatComponent combComp   = filter.combatComponent;
            HealthComponent healthComp = filter.healthComponent;

            // ----- logic -----
            if (gameOver)
            {
                if (Input.GetKeyDown(KeyCode.F))
                {
                    Restart();
                }
                alpha += deltaTime * 0.3f;
            }

            float dst = Vector3.Distance(filter.gameObject.transform.position, inputComponent.transform.position);
            if (dst > enemyComp.aggroRange)
            {
                enemyComp.agent.ResetPath();
                return;
            }

            if (inputComponent.avoidPlayer)
            {
                enemyComp.isPursuingTransportable = false;
                //EngageTransform(enemyComp, returnGO.transform);
            }

            if (enemyComp.isActive)
            {
                if (!inputComponent.avoidPlayer)
                {
                    //EngageTransform(enemyComp, inputComponent.gameObject.transform);
                }
            }

            /*float remainingDist = Vector3.Distance(enemyComp.transform.position, transportableComponent.transform.position);
             * if (enemyComp.agent.hasPath && remainingDist < 2f)
             * {
             *  gameOver = true;
             *  loseTXT.gameObject.SetActive(true);
             *  blockIMG.gameObject.SetActive(true);
             *  blockIMG.color = new Color(blockIMG.color.r, blockIMG.color.g, blockIMG.color.b, alpha);
             * }*/
        }
    }
Esempio n. 30
0
    //SPAWN ENEMIES
    private void SpawnEnemies()
    {
        enemiesList = new List <EnemyComponent>();
        for (int j = 0; j < 5; j++)
        {
            EnemyComponent e = Instantiate(enemyPrefab) as EnemyComponent;

            e.enemyType = (EnemyTypeEnum)(j % 3);
            e.TeleportTo(Map.rooms[Random.Range(0, Map.rooms.Count)].GetRandomContentTile());
            enemiesList.Add(e);
            e.enabled = false;
        }
    }
    public override bool Verify(StateComponent smComponent)
    {
        Vector2   position = smComponent.transform.position;
        Transform target   = Physics2D.OverlapCircle(position, detectionRadius, detectionLayer)?.transform;

        EnemyComponent component = smComponent.GetComponent <EnemyComponent>();

        if (component)
        {
            component.SetTarget(target);
        }

        return(target != null);
    }
	public void initAttackObjects ( EnemyComponent.HandleAttackExecuted callBackWhenAttackExecuted, EnemyData enemyAttacked, CharacterData attackingCharacter = null )
	{
		_callBackWhenAttackExecuted = callBackWhenAttackExecuted;
		_enemyAttacked = enemyAttacked;
		_characterAttacking = attackingCharacter;
		_startProgressBar = true;
		
		if ((( GameGlobalVariables.CURRENT_GAME_PART == GameGlobalVariables.RESCUE && GlobalVariables.TUTORIAL_MENU ) ||  GameGlobalVariables.CURRENT_GAME_PART == GameGlobalVariables.MINING && MNGlobalVariables.TUTORIAL_MENU ) /*====Daves Edit=====*/&& (LevelControl.LEVEL_ID == 2)/*====Daves Edit=====*/ &&( TutorialsManager.getInstance ().getCurrentTutorialStep ().type != TutorialsManager.TUTORIAL_OBJECT_TYPE_DESTROY_OBJECTS ))
		{
			if ( LevelControl.LEVEL_ID != 16 )
			{
				_tutorialHandInstant = ( GameObject ) Instantiate ( _tutorialHandPrefab, transform.position + Vector3.right * 1f + Vector3.up * 1f + Vector3.back * 2f, transform.rotation );
				_tutorialHandInstant.transform.parent = transform;
			}
		}
	}
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory = new AggregateFactory(this);
            WeaponFactory = new WeaponFactory(this);
            DoorFactory = new DoorFactory(this);
            RoomFactory = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory = new WallFactory(this);
            EnemyFactory = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory = new NPCFactory(this);

            // Initialize Components
            PlayerComponent = new PlayerComponent();
            LocalComponent = new LocalComponent();
            RemoteComponent = new RemoteComponent();
            PositionComponent = new PositionComponent();
            MovementComponent = new MovementComponent();
            MovementSpriteComponent = new MovementSpriteComponent();
            SpriteComponent = new SpriteComponent();
            DoorComponent = new DoorComponent();
            RoomComponent = new RoomComponent();
            HUDSpriteComponent = new HUDSpriteComponent();
            HUDComponent = new HUDComponent();
            InventoryComponent = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent = new EquipmentComponent();
            WeaponComponent = new WeaponComponent();
            BulletComponent = new BulletComponent();
            PlayerInfoComponent = new PlayerInfoComponent();
            WeaponSpriteComponent = new WeaponSpriteComponent();
            StatsComponent = new StatsComponent();
            EnemyAIComponent = new EnemyAIComponent();
            NpcAIComponent = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent = new CollisionComponent();
            TriggerComponent = new TriggerComponent();
            EnemyComponent = new EnemyComponent();
            NPCComponent = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent = new SoundComponent();
            ActorTextComponent = new ActorTextComponent();
            TurretComponent = new TurretComponent();
            TrapComponent = new TrapComponent();
            ExplodingDroidComponent = new ExplodingDroidComponent();
            HealingStationComponent = new HealingStationComponent();
            PortableShieldComponent = new PortableShieldComponent();
            PortableStoreComponent = new PortableStoreComponent();
            ActiveSkillComponent = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();

            Quests = new List<Quest>();

            #region Initialize Effect Components
            AgroDropComponent = new AgroDropComponent();
            AgroGainComponent = new AgroGainComponent();
            BuffComponent = new BuffComponent();
            ChanceToSucceedComponent = new ChanceToSucceedComponent();
            ChangeVisibilityComponent = new ChangeVisibilityComponent();
            CoolDownComponent = new CoolDownComponent();
            DamageOverTimeComponent = new DamageOverTimeComponent();
            DirectDamageComponent = new DirectDamageComponent();
            DirectHealComponent = new DirectHealComponent();
            FearComponent = new FearComponent();
            HealOverTimeComponent = new HealOverTimeComponent();
            InstantEffectComponent = new InstantEffectComponent();
            KnockBackComponent = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent = new ReduceAgroRangeComponent();
            ResurrectComponent = new ResurrectComponent();
            StunComponent = new StunComponent();
            TimedEffectComponent = new TimedEffectComponent();
            EnslaveComponent = new EnslaveComponent();
            CloakComponent = new CloakComponent();
            #endregion

            base.Initialize();
        }
	public void moveHereAndCallThis ( Vector3 positionToMove, EnemyComponent.HandleFinishedAnimationMove callBackWhenFinidhedMove, bool success, bool withBoune = false )
	{
		_initialPosition = VectorTools.cloneVector3 ( transform.position );
		
		_myCallBackWhenFinishedMove = callBackWhenFinidhedMove;
		_moveSucesfull = success;
		
		if ( withBoune ) iTween.MoveTo ( this.gameObject, iTween.Hash ( "time", 0.15f, "easetype", iTween.EaseType.linear, "position", positionToMove + Vector3.forward * 0.5f, "oncompletetarget", this.gameObject, "oncomplete", "onCompleteTweenAnimationMoveToPositionWithBounce" ));
		else iTween.MoveTo ( this.gameObject, iTween.Hash ( "time", 0.25f, "easetype", iTween.EaseType.easeInOutCubic, "position", positionToMove + Vector3.forward * 0.5f, "oncompletetarget", this.gameObject, "oncomplete", "onCompleteTweenAnimationMoveToPosition" ));
	}
Esempio n. 35
0
 public void OnKillEnemy(EnemyComponent enemy)
 {
     var score = GetEnemyKillScore(enemy.enemyType);
     Player.Main.WaveScore += score;
     Player.Main.TotalScore += score;
 }
 void Awake()
 {
     mPartyComponent = GameObject.FindGameObjectWithTag(Tags.GAME_CONTROLLER).GetComponent<PartyComponent>();
     mEnemyComponent = GameObject.FindGameObjectWithTag(Tags.ENEMY).GetComponent<EnemyComponent>();
 }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory = new AggregateFactory(this);
            WeaponFactory = new WeaponFactory(this);
            DoorFactory = new DoorFactory(this);
            RoomFactory = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory = new WallFactory(this);
            EnemyFactory = new EnemyFactory(this);

            // Initialize Components
            PlayerComponent = new PlayerComponent();
            LocalComponent = new LocalComponent();
            RemoteComponent = new RemoteComponent();
            PositionComponent = new PositionComponent();
            MovementComponent = new MovementComponent();
            MovementSpriteComponent = new MovementSpriteComponent();
            SpriteComponent = new SpriteComponent();
            DoorComponent = new DoorComponent();
            RoomComponent = new RoomComponent();
            HUDSpriteComponent = new HUDSpriteComponent();
            HUDComponent = new HUDComponent();
            InventoryComponent = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent = new EquipmentComponent();
            WeaponComponent = new WeaponComponent();
            BulletComponent = new BulletComponent();
            PlayerInfoComponent = new PlayerInfoComponent();
            WeaponSpriteComponent = new WeaponSpriteComponent();
            StatsComponent = new StatsComponent();
            EnemyAIComponent = new EnemyAIComponent();
            CollectibleComponent = new CollectibleComponent();
            CollisionComponent = new CollisionComponent();
            TriggerComponent = new TriggerComponent();
            EnemyComponent = new EnemyComponent();
            QuestComponent = new QuestComponent();
            LevelManager = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();

            //TurretComponent = new TurretComponent();
            //TrapComponent = new TrapComponent();
            //PortableShopComponent = new PortableShopComponent();
            //PortableShieldComponent = new PortableShieldComponent();
            //MotivateComponent =  new MotivateComponent();
            //FallbackComponent = new FallbackComponent();
            //ChargeComponent = new ChargeComponent();
            //HealingStationComponent = new HealingStationComponent();
            //ExplodingDroidComponent = new ExplodingDroidComponent();

            base.Initialize();
        }