Example #1
0
 // Start is called before the first frame update
 void Start()
 {
     basicAttack   = gameObject.AddComponent <BasicAttack>();
     trippleAttack = gameObject.AddComponent <TrippleAttack>();
     healSkill     = gameObject.AddComponent <HealSkill>();
     //ba.ActivateSkill(addEnemyDamage);
 }
Example #2
0
    // Use this for initialization
    void Start()
    {
        c_playerHealthScript = GetComponent <PlayerHealth> ();
        c_UI            = GameObject.FindGameObjectWithTag("UICanvas").GetComponent <UIControl>();
        c_personalDelay = 30 / c_playerHealthScript.c_playerStats.playerSpeed;
        c_myTurnObject  = new TurnObject(gameObject, c_personalDelay);
        TurnOrder.s_turnOrderList.Add(c_myTurnObject);
        c_myTurnObject.c_myIndex = (TurnOrder.s_turnOrderList.Count - 1);
        if (c_myTurn)
        {
            c_UI.UpdateActiveCharacter(gameObject);
        }
        if (c_enemy != null)
        {
            c_enemyHealthScript = c_enemy.GetComponent <PlayerHealth> ();
        }
        c_playerMove            = GetComponent <PlayerMoveAStar> ();
        c_playerMoveRangeScript = GetComponent <PlayerMoveRangeDijkstra> ();
        c_saveStartPosition     = transform.position;

        c_squaresInMoveRange   = new List <GameObject>();
        c_squaresInAttackRange = new List <GameObject> ();
        c_enemiesInAttackRange = new List <GameObject> ();
        c_attacked             = false;
        c_setupAttack          = false;
        c_resetMove            = false;
        c_currentSkill         = c_characterSkills [0];
        if (!c_myTurn)
        {
            c_particleComponent.Stop();
        }
    }
Example #3
0
        private GameObject m_CanvasGameObject;                  // Used to disable the world space UI during the Starting and Ending phases of each round.


        public void Setup()
        {
            // Get references to the components.
            m_Movement         = m_Instance.GetComponent <TankMovement>();
            m_Shooting         = m_Instance.GetComponent <TankShooting>();
            m_Skill            = m_Instance.GetComponent <AbstractSkill>();
            m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas>().gameObject;

            // Set the player numbers to be consistent across the scripts.
            m_Movement.m_PlayerNumber = m_PlayerNumber;
            m_Shooting.m_PlayerNumber = m_PlayerNumber;
            m_Skill.m_PlayerNumber    = m_PlayerNumber;

            // Create a string using the correct color that says 'PLAYER 1' etc based on the tank's color and the player's number.
            m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>";

            // Get all of the renderers of the tank.
            MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer>();

            // Go through all the renderers...
            for (int i = 0; i < renderers.Length; i++)
            {
                // ... set their material color to the color specific to this tank.
                renderers[i].material.color = m_PlayerColor;
            }
        }
Example #4
0
    // Load in skill prefabs and parent their hitboxes and scripts under the hero unit
    private void CreateSkills()
    {
        GameObject whirlwind = (GameObject)Instantiate(whirlwindPrefab, transform.position, Quaternion.identity);

        whirlwind.transform.SetParent(transform);
        WhirlwindSkill skill = whirlwind.GetComponent <WhirlwindSkill>();

        skill.SetHero(this);
        whirlwind.SetActive(false);
        activeSkill = skill;
    }
Example #5
0
        /// <summary>
        /// Sends a SkillInfo to
        /// the entity's GridCell and it's neighbours.
        /// Clients will simulate skills entity targeted skills based on this message.
        /// </summary>
        /// <param name="skill">Skill that has been casted.</param>
        public void SendSkillOnCasted(AbstractSkill skill)
        {
            NetBuffer buffer = new NetBuffer();

            buffer.Write((byte)MessageType.SkillInfo);

            buffer.Write((byte)skill.SkillId);
            buffer.Write((ushort)skill.Caster.Id, 16);

            buffer.Write((ushort)skill.Target.Id, 16);


            SendDataToNeigbours(buffer.Data, skill.Caster.GridCell);
        }
Example #6
0
        public void CopyInto(AbstractSkill skill)
        {
            skill.SkillId = this.SkillId;
            skill.State   = this.State;

            skill.School = this.School;

            skill.CostType  = this.CostType;
            skill.CostValue = this.CostValue;

            skill.CastDuration = this.CastDuration;

            skill.DamageMultiplier = this.DamageMultiplier;
            skill.Cooldown         = this.Cooldown;
            skill.MaxTargetRange   = this.MaxTargetRange;
        }
    // Performs a skill at a given index within the skillbar
    public bool performSkillAtIndex(int i, List <AbstractCreature> targets, CombatData data, AbstractCreature skillUser)
    {
        if (i < 0 || i >= skillBar.Length)
        {
            //Attempting to get a skill out of array bounds
            SkillEvent("No skill found!");
            return(false);
        }
        else
        {
            if (skillToUse != null && skillToUse != skillBar[i])
            {
                skillToUse.destroySRI();
                SkillEvent(skillToUse.unprepareSkill());
            }

            skillToUse = skillBar[i];

            if (skillToUse.isPrepared())
            {
                SkillEvent(skillToUse.attemptSkill(targets, data));
                Destroy(skillRadiusIndicator);
            }
            else
            {
                SkillEvent(skillToUse.prepareSkill());
                if (skillToUse.isPrepared())
                {
                    skillRadiusIndicator = (GameObject)Instantiate(Resources.Load("SRI"));
                    skillRadiusIndicator.transform.localScale = skillRadiusIndicator.transform.localScale * skillBar[i].skillRadius;
                    skillRadiusIndicator.transform.position   = parent.transform.position;
                    skillToUse.SkillRadiusIndicator           = skillRadiusIndicator;
                }
            }
            return(skillBar[i].skillSuccessful);
        }
    }
Example #8
0
        /// <summary>
        /// Sends SkillInfoAlternativePosition message to
        /// the entity's GridCell and it's neighbours.
        /// Clients will be able simulate skills that start position is not from their entity position based on this message.
        /// Skill Like: ChainLightning
        /// </summary>
        /// <param name="skill">Skill that has been casted</param>
        /// <param name="alternativeEntity">The entity the skills starts from.</param>
        public void SendSkillOnCastedAlternativePosition(AbstractSkill skill, Entity alternativeEntity)
        {
            NetOutgoingMessage msgOut;

            foreach (var gridCell in skill.Caster.GridCell.Neighbours)
            {
                if (gridCell != null)
                {
                    foreach (var entity in gridCell.PlayersById.Values)
                    {
                        msgOut = Server.CreateMessage();

                        msgOut.Write((byte)MessageType.SkillInfoAlternativePosition);

                        msgOut.Write((byte)skill.SkillId);
                        msgOut.Write((ushort)skill.Caster.Id, 16);

                        msgOut.Write((ushort)skill.Target.Id, 16);
                        if (alternativeEntity != null)
                        {
                            msgOut.Write((ushort)alternativeEntity.Id, 16);
                        }
                        else
                        {
                            msgOut.Write(skill.Caster.Id);
                        }


                        if (entity.Connection != null)
                        {
                            entity.Connection.SendMessage(msgOut, NetDeliveryMethod.Unreliable, 0);
                        }
                    }
                }
            }
        }
Example #9
0
 public void SetCurrentSkill(int l_skillNum)
 {
     c_currentSkill = c_characterSkills [l_skillNum];
 }
Example #10
0
        /// <summary>
        /// The message read loop will call this for
        /// NetIncomingMessageType.Data typed NetIncomingMessages
        /// </summary>
        /// <param name="msgType">The MessageType of the message which the client sent !!!NOT THE SAME AS NetIncomingMessageType!!!</param>
        /// <param name="msgIn">The message from the client</param>
        private void HandleMessage(MessageType msgType, NetIncomingMessage msgIn)
        {
            // Based on the NetIncomingMessage RemoteUniqueIdentifier (UID) gets the PlayerEntity from the WorldData
            PlayerEntity entity = Server.Data.Get(msgIn.SenderConnection.RemoteUniqueIdentifier);

            if (entity != null)
            {
                switch (msgType)
                {
                case MessageType.Respawn:
                {
                    bool homeOrNearest = msgIn.ReadBoolean();
                    if (entity.isDead)
                    {
                        entity.isDead = false;
                        entity.Respawn();
                    }
                }
                break;

                case MessageType.PlayerMovement:

                    if (!entity.isDead)
                    {
                        Vector3 newPosition = new Vector3(msgIn.ReadFloat(), 0, msgIn.ReadFloat());

                        if (CheckPosition(entity, newPosition))
                        {
                            return;
                        }

                        entity.SetPosition(newPosition);

                        if (entity.IsSkillCasting)
                        {
                            if (Vector3.SqrDistance(entity.ChannelingPosition, entity.Position) > 2f)
                            {
                                entity.IsSkillCasting = false;
                            }
                        }
                    }
                    break;

                case MessageType.Interact:
                {
                    EntityBase interactedEntity = Server.Data.GetInteractedEntity(msgIn.ReadUInt16());
                    interactedEntity.Interact(entity);
                }
                break;

                case MessageType.SkillRequestRawPosition:
                {
                    Console.WriteLine("RAW SKILL");
                    SkillID skillId        = (SkillID)msgIn.ReadByte();
                    Vector3 targetPosition = new Vector3(msgIn.ReadFloat(), 0, msgIn.ReadFloat());

                    if (entity != null)
                    {
                        AbstractSkill skill = SkillFactory.Instance.GetSkill(skillId);

                        skill.Create(entity, targetPosition, Server);

                        if (entity.AddSkill(skill))
                        {
                            Console.WriteLine("ADDED");
                        }
                        else
                        {
                            Console.WriteLine("FAILED TO ADD");
                        }
                    }
                }
                break;

                case MessageType.SkillRequest:
                {
                    Entity  target  = Server.Data.Get(msgIn.ReadUInt16());
                    SkillID skillId = (SkillID)msgIn.ReadByte();

                    Console.WriteLine("DEFAULT CHECK");
                    if (target != null && entity != null && target.Health.Value > 0 && !entity.IsSkillCasting)
                    {
                        Console.WriteLine("RANGE CHECK...");
                        AbstractSkill skill = SkillFactory.Instance.GetSkill(skillId);

                        if (Vector3.SqrDistance(entity.Position, target.Position) < skill.MaxTargetRange * skill.MaxTargetRange)
                        {
                            Console.WriteLine("OK");
                            skill.Create(entity, target, Server);
                            float tickTime        = 1000f / Server.PlayerTickRate;
                            float lagCompensation = (int)((entity.Connection.AverageRoundtripTime * 1000f) / tickTime);
                            skill.CastDuration -= (int)lagCompensation;

                            if (entity.AddSkill(skill))
                            {
                                Console.WriteLine("ADDED");
                            }
                            else
                            {
                                Console.WriteLine("FAILED TO ADD");
                            }
                        }
                    }
                }
                break;
                }
            }
        }
Example #11
0
 public abstract void Upgrade(AbstractSkill skil);
Example #12
0
 public void Select(AbstractSkill skill)
 {
     this.skill = skill;
 }
Example #13
0
 public override void AddSkill(AbstractSkill skill, Vector3 position)
 {
     Server.OutgoingMessageHandler.SendChannelingInfo(this);
     IsSkillCasting = true;
     Skills.Add(skill);
 }