Ejemplo n.º 1
0
 public void SelectCharacter(Character2D NewCharacter, bool IsForce = false)
 {
     if (SelectedCharacter != NewCharacter || IsForce)
     {
         if (SelectedCharacter != null)
         {
             SelectedCharacter.OnHealthUpdatedEvent.RemoveListener(OnHealthUpdated);
             SelectedCharacter.OnHealthRegenUpdatedEvent.RemoveListener(OnHealthRegenUpdated);
         }
         SelectedCharacter = NewCharacter;
         if (SelectedCharacter)
         {
             MyTabs.SelectSelect();
             gameObject.SetActive(true);
             IsSelected = true;
             SelectedCharacter.OnHealthUpdatedEvent.AddListener(OnHealthUpdated);
             SelectedCharacter.OnHealthRegenUpdatedEvent.AddListener(OnHealthRegenUpdated);
             OnNameUpdated();
             OnHealthUpdated();
             OnHealthRegenUpdated();
             OnDamageUpdated();
             OnAttackSpeedUpdated();
             OnRangeUpdated();
             OnVisionUpdated();
         }
         else
         {
             NameText.text = "None Selected";
             gameObject.SetActive(false);
         }
     }
 }
Ejemplo n.º 2
0
        void OnTriggerStay2D(Collider2D other)
        {
            Character2D PossibleUser = other.gameObject.GetComponent <Character2D>();

            if (PossibleUser && MyCharacters.Contains(PossibleUser))
            {
                int Index = MyCharacters.IndexOf(PossibleUser);
                if (Time.time - TimeEntered[Index] >= TeleportTime)
                {
                    Debug.Log("Teleporting and removing " + PossibleUser.name);
                    PossibleUser.transform.position = OtherTeleporter.transform.position;
                    UserControl2D MyUser = PossibleUser.gameObject.GetComponent <UserControl2D>();
                    if (MyUser)
                    {
                        MyUser.TeleportCamera();
                    }

                    /*if (IsParticlesAnimating)
                     * {
                     *  GameObject MyParticleSpawn = Instantiate(TeleporterParticles, transform.position);
                     * }*/
                    GameObject MyParticleSpawn = Instantiate(TeleporterParticles, transform.position, Quaternion.identity);
                    Destroy(MyParticleSpawn, 6f);
                    GameObject MyParticleSpawn2 = Instantiate(TeleporterParticles, OtherTeleporter.transform.position, Quaternion.identity);
                    Destroy(MyParticleSpawn2, 6f);
                    MyParticleSpawn.transform.eulerAngles  = new Vector3(90, 0, 0);
                    MyParticleSpawn2.transform.eulerAngles = new Vector3(90, 0, 0);

                    MyCharacters.RemoveAt(Index);
                    TimeEntered.RemoveAt(Index);
                    OtherTeleporter.IgnoreForCharacter(PossibleUser);
                    StartCoroutine(DisableCharacterForTime(PossibleUser));
                }
            }
        }
Ejemplo n.º 3
0
 public void GetHit(Character2D MyCharacter, float Damage = -1)
 {
     if (Health > 0)
     {
         if (Damage == -1)
         {
             Damage = MyCharacter.AttackDamage;
         }
         LastTakenHit = Time.time;
         Health      -= Damage;
         Health       = Mathf.Clamp(Health, 0, MaxHealth);
         MapData.Instance.CreateHealthPopup(transform.position, Damage, 0);
         OnHealthUpdatedEvent.Invoke();
         if (MyHealthBar)
         {
             MyHealthBar.SetBars(Health);
         }
         if (MyControl)
         {
             MyControl.OnHit(MyCharacter);
         }
         if (Health == 0 && IsDestroyOnZeroHealth && !IsDying)
         {
             IsDying = true;
             MapData.Instance.SpawnedCharacters.Remove(gameObject);
             MyHealthBar.SetVisibility(false);
             SetMovement(false);
             ShrinkDeath MyDeath = gameObject.AddComponent <ShrinkDeath>();
             MyDeath.SetDeathTime(0.4f);
             MyCharacter.OnKilledCharacter(this);
         }
     }
 }
Ejemplo n.º 4
0
 public virtual void SelectCharacter(Character2D NewSelectedCharacter)
 {
     if (NewSelectedCharacter && NewSelectedCharacter.MyDialogue)
     {
         SelectedCharacter = NewSelectedCharacter;
         SelectedCharacter.Glow();
     }
 }
Ejemplo n.º 5
0
 public virtual void DeSelectCharacter(Character2D NewSelectedCharacter)
 {
     if (NewSelectedCharacter == SelectedCharacter && SelectedCharacter != null)
     {
         SelectedCharacter.RemoveGlow();
         SelectedCharacter.MyDialogue.StopSpeak();
         SelectedCharacter = null;
     }
 }
Ejemplo n.º 6
0
 public void OnHit(Character2D MyCharacter)
 {
     if (MyCharacter && MyBehaviour != MinionBehaviour.Attack)
     {
         MinimumDistanceToTarget = 0f;
         BeforeAttackBehaviour   = MyBehaviour;
         MyBehaviour             = MinionBehaviour.Attack;
         AttackTransform         = MyCharacter.transform;
     }
 }
Ejemplo n.º 7
0
        void OnTriggerEnter2D(Collider2D other)
        {
            Character2D PossibleUser = other.gameObject.GetComponent <Character2D>();

            if (PossibleUser && MyCharacters.Contains(PossibleUser) == false)
            {
                Debug.Log("Adding " + PossibleUser.name);
                MyCharacters.Add(PossibleUser);
                TimeEntered.Add(Time.time);
            }
        }
Ejemplo n.º 8
0
        void OnTriggerEnter2D(Collider2D other)
        {
            Character2D PossibleUser = other.gameObject.GetComponent <Character2D>();

            if (!IsProgressing && PossibleUser && PossibleUser.name == "MrPenguin")
            {
                Debug.Log("Progressing " + PossibleUser.name);
                IsProgressing = true;
                StartCoroutine(ProgressLevelRoutine());
            }
        }
Ejemplo n.º 9
0
 // Update is called once per frame
 void Update()
 {
     if (Time.time - LastScanTime >= ScanCooldown && !MyController.IsAttacking())
     {
         LastScanTime = Time.time;
         ClosestTower = MapData.Instance.GetClosestIshWithTag("Tower", transform.position, 2);
         if (ClosestTower != null)
         {
             MyController.Attack(ClosestTower.transform);
         }
     }
 }
Ejemplo n.º 10
0
 public void IgnoreForCharacter(Character2D PossibleUser)
 {
     if (MyCharacters.Contains(PossibleUser))
     {
         int Index = MyCharacters.IndexOf(PossibleUser);
         MyCharacters.RemoveAt(Index);
         TimeEntered.RemoveAt(Index);
         Debug.Log("Removing " + PossibleUser.name);
     }
     MyCharacters.Add(PossibleUser);
     TimeEntered.Add(1000000000); // never activate
 }
Ejemplo n.º 11
0
 private void SetCharacterMovement(Character2D MyCharacter, bool NewState)
 {
     if (MyCharacter)
     {
         MyCharacter.SetMovement(NewState);
         UserControl2D MyControl = MyCharacter.gameObject.GetComponent <UserControl2D>();
         if (MyControl)
         {
             MyControl.enabled = NewState;
         }
     }
 }
Ejemplo n.º 12
0
        void OnTriggerExit2D(Collider2D other)
        {
            Character2D PossibleUser = other.gameObject.GetComponent <Character2D>();

            if (PossibleUser && MyCharacters.Contains(PossibleUser))
            {
                Debug.Log("Removing " + PossibleUser.name);
                int Index = MyCharacters.IndexOf(PossibleUser);
                MyCharacters.RemoveAt(Index);
                TimeEntered.RemoveAt(Index);
            }
        }
Ejemplo n.º 13
0
        /*public void SpawnMinions()
         * {
         *  StartCoroutine(SpawnMinionsRoutine());
         * }
         *
         * public IEnumerator SpawnMinionsRoutine()
         * {
         *  yield return new WaitForSeconds(InitialDelay);
         *  SpawnMinion();
         * }*/

        public void SpawnMinion()
        {
            Vector3 SpawnPosition = Camera.main.ScreenPointToRay(Input.mousePosition).origin;

            SpawnPosition.z = 0;
            GameObject MySpawn = Instantiate(CharacterPrefab, GetRandomPosition(), Quaternion.identity, transform);

            MapData.Instance.SpawnedCharacters.Add(MySpawn);
            Spawns.Add(MySpawn);
            Character2D MyCharacter = MySpawn.GetComponent <Character2D>();

            MyCharacter.SetLevel(SpawnLevel);
        }
Ejemplo n.º 14
0
 void OnCollisionEnter2D(Collision2D other)
 {
     if (!WasHit)
     {
         //Debug.LogError(other.gameObject.name + " has entered " + transform.parent.name);
         Character2D HitCharacter = other.gameObject.GetComponent <Character2D>();
         if (HitCharacter && HitCharacter.gameObject.tag == "Minion")
         {
             WasHit = true;
             gameObject.AddComponent <ShrinkDeath>();
             HitCharacter.GetHit(ShooterCharacter, AttackDamage);
         }
     }
 }
Ejemplo n.º 15
0
 private void Awake()
 {
     m_Character = GetComponent <Character2D>();
     WanderValue = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f));
     if (MyCircleCollider == null)
     {
         MyCircleCollider = GetComponent <CircleCollider2D>();
     }
     if (MyBoxCollider == null)
     {
         MyBoxCollider = GetComponent <BoxCollider2D>();
     }
     MyCharacter = GetComponent <Character2D>();
     WanderValue.Normalize();
 }
Ejemplo n.º 16
0
        private IEnumerator SpawnInTime()
        {
            Vector3 SpawnPosition = MyTowerBuilder.transform.position;

            yield return(new WaitForSeconds(0.5f));

            Character2D SpawnedCharacter = MyTowerBuilder.SpawnTower(SpawnPosition).GetComponent <Character2D>();

            yield return(new WaitForSeconds(4f));

            ExplorationGui.interactable = true;
            MyTowerBuilder.OnBeginGame();
            MyTowerBuilder.SelectTower(SpawnedCharacter);
            MySpawner.OnBeginGame();
        }
Ejemplo n.º 17
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (TargetCharacter)
     {
         Character2D TriggeredCharacter = other.gameObject.GetComponent <Character2D>();
         if (TriggeredCharacter)
         {
             TargetCharacter.DeSelectCharacter(TriggeredCharacter);
             return;
         }
         Item TriggeredItem = other.gameObject.GetComponent <Item>();
         if (TriggeredItem)
         {
             TargetCharacter.DeSelectItem(TriggeredItem);
         }
     }
 }
Ejemplo n.º 18
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (TargetCharacter)
     {
         //Debug.LogError(other.gameObject.name + " has entered " + transform.parent.name);
         Character2D TriggeredCharacter = other.gameObject.GetComponent <Character2D>();
         if (TriggeredCharacter)
         {
             TargetCharacter.SelectCharacter(TriggeredCharacter);
             return;
         }
         Item TriggeredItem = other.gameObject.GetComponent <Item>();
         if (TriggeredItem)
         {
             TargetCharacter.SelectItem(TriggeredItem);
         }
     }
 }
Ejemplo n.º 19
0
        public void SpawnBossMinion()
        {
            Vector3 SpawnPosition = Camera.main.ScreenPointToRay(Input.mousePosition).origin;

            SpawnPosition.z = 0;
            GameObject MySpawn = Instantiate(CharacterPrefab, GetRandomPosition(), Quaternion.identity, transform);

            MapData.Instance.SpawnedCharacters.Add(MySpawn);
            Spawns.Add(MySpawn);
            Character2D MyCharacter = MySpawn.GetComponent <Character2D>();

            MyCharacter.SetLevel(Mathf.RoundToInt(SpawnLevel * MaxMinionsToSpawn * 4f));
            MyCharacter.SetSize(2.5f);
            MyCharacter.SetMovementSpeed(0.5f);
            Generators.TextureGenerator MyGenerator = MySpawn.transform.GetChild(0).GetComponent <Generators.TextureGenerator>();
            MyGenerator.IsAddOutline = true;
            if (MyGenerator.HasStarted)
            {
                Debug.LogError("Regenerating boss sprite.");
                MyGenerator.GenerateSprite();
            }
        }
Ejemplo n.º 20
0
        private IEnumerator DisableCharacterForTime(Character2D PossibleUser)
        {
            //PossibleUser.gameObject.SetActive(false);
            UserControl2D   MyUser   = PossibleUser.gameObject.GetComponent <UserControl2D>();
            MinionControl2D MyMinion = PossibleUser.gameObject.GetComponent <MinionControl2D>();

            PossibleUser.enabled = false;
            PossibleUser.transform.GetChild(0).gameObject.SetActive(false);
            if (MyUser)
            {
                MyUser.enabled = false;
            }
            else if (MyMinion)
            {
                MyMinion.enabled = false;
            }
            yield return(new WaitForSeconds(1f));

            PossibleUser.transform.GetChild(0).gameObject.SetActive(true);
            float   TimeBegun      = Time.time;
            Vector3 OriginalVector = PossibleUser.transform.localScale;

            while (Time.time - TimeBegun <= 1.5f)
            {
                PossibleUser.transform.localScale = Vector3.Lerp(new Vector3(0.1f, 0.1f, 0.1f), OriginalVector, (Time.time - TimeBegun) / 1.5f);
                yield return(null);
            }
            PossibleUser.transform.localScale = OriginalVector;
            //PossibleUser.gameObject.SetActive(true);
            PossibleUser.enabled = true;
            if (MyUser)
            {
                MyUser.enabled = true;
            }
            else if (MyMinion)
            {
                MyMinion.enabled = true;
            }
        }
Ejemplo n.º 21
0
 private void ShootAtMinion()
 {
     if (TargetMinion == null)
     {
         TargetMinion = MapData.Instance.GetClosestWithTag("Minion", transform.position, FireRange);
     }
     if (TargetMinion && FoW.FogOfWar.current.IsInFog(TargetMinion.transform.position + new Vector3(-0.5f, -0.5f, 0), 0.2f))
     {
         TargetMinion = null;
     }
     if (TargetMinion)
     {
         // Check that minion is in fog!
         Vector2     BulletDirection = (TargetMinion.transform.position - transform.position).normalized;
         GameObject  MyBullet        = Instantiate(BulletPrefab, transform.position + FireSpawnOffset * (new Vector3(BulletDirection.x, BulletDirection.y, 0)), Quaternion.Euler(BulletDirection.x, BulletDirection.y, 0));
         Rigidbody2D BulletPhysics   = MyBullet.GetComponent <Rigidbody2D>();
         BulletPhysics.AddForce(BulletDirection * FireForce);
         Bullet MyBulletComponent = MyBullet.GetComponent <Bullet>();
         MyBulletComponent.ShooterCharacter = MyCharacter;
         MyBulletComponent.AttackDamage     = MyCharacter.AttackDamage;
         MyBulletComponent.DeathTime        = MyCharacter.Range / 2f;
         AimLine.SetPositions(new Vector3[] { transform.position, transform.position + 0.3f * (new Vector3(BulletDirection.x, BulletDirection.y, 0)) });
     }
 }
Ejemplo n.º 22
0
 public void OnKilledCharacter(Character2D DeadCharacter)
 {
     KillCount++;
     OnKilledCharacterEvent.Invoke(DeadCharacter);
 }
Ejemplo n.º 23
0
 private void Awake()
 {
     MyCharacter = GetComponent <Character2D>();
 }
Ejemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     LastFired   = Time.time;
     MyCharacter = GetComponent <Character2D>();
     AimLine.SetPositions(new Vector3[] { transform.position, transform.position + 0.3f * (new Vector3(0, 1f, 0)) });
 }