Esempio n. 1
0
        // Start is called before the first frame update
        public virtual void Start()
        {
            //Initialize important stuff i guess
            p_Attributes    = new Dictionary <ATTRIBUTES, short>();
            playerCamera    = GetComponent <Camera>();
            current_Mods    = new CHARACTER_MODIFIER[19]; //Number of possible mods
            characterLevels = new short[53, 3];           //Number of characters and possible levels
            field_Units     = new SyncListCharacter();
            bench_Units     = new SyncListCharacter();
            benchZPosition  = transform.position.z + 6;

            synergiesText = transform.GetChild(0).GetChild(3).GetComponent <Text>();

            playerCanvas  = transform.GetChild(0).GetComponent <Canvas>();
            playerShop    = GetComponentInChildren <Shop>();
            m_Raycaster   = playerCanvas.GetComponent <GraphicRaycaster>();
            ui_Results    = new List <RaycastResult>();
            m_Eventsystem = GetComponent <EventSystem>();

            if (isLocalPlayer)
            {
                GetComponent <AudioListener>().enabled = true;
                playerCamera.enabled = true;
                playerCanvas.gameObject.SetActive(true);
            }
        }
Esempio n. 2
0
 //Start is called before the first frame update
 public override void Start()
 {
     p_Attributes    = new Dictionary <ATTRIBUTES, short>();
     current_Mods    = new CHARACTER_MODIFIER[19]; //Number of possible mods
     characterLevels = new short[53, 3];           //Number of characters and possible levels
     field_Units     = new SyncListCharacter();
     bench_Units     = new SyncListCharacter();
     benchZPosition  = transform.position.z + 6;
 }
Esempio n. 3
0
 //Method to determine if a unit with a valid ID exists in the
 //given context
 private int FindUnitID(SyncListCharacter units, short ID, short level)
 {
     for (int i = 0; i < units.Count; i++)
     {
         if (units[i].ID == ID && units[i].level == level)
         {
             return(i);
         }
     }
     return(-1);
 }
Esempio n. 4
0
        //Simulate combat between two players by determining the next action of their units
        private void SimulateCombat(SyncListCharacter fielded_Units, SyncListCharacter enemy_Units)
        {
            //Loop through the first player's units and determine what they should do
            foreach (Character c in fielded_Units)
            {
                if (c.isActiveAndEnabled)
                {
                    if (c.target == null)
                    {
                        //Find the next target based on the relative distance between
                        //the enemy and the character
                        float shortestDistance = float.MaxValue, distance = 0;
                        foreach (Character e in enemy_Units)
                        {
                            distance = Vector3.Distance(c.transform.position, e.transform.position);
                            if (distance < shortestDistance && e.health >= 0)
                            {
                                shortestDistance = distance;
                                c.target         = e;
                            }
                        }
                    }
                    else
                    {
                        int current_Distance = (int)Vector2.Distance(c.grid_Position, c.target.grid_Position);
                        //Debug.Log(c.grid_Position + " " + c.target.grid_Position);

                        //Determine if a new path needs to be generated
                        Debug.Log(c.grid_Position + " | " + c.target.grid_Position);
                        if (!c.Moving(current_Distance) && current_Distance > c.range)
                        {
                            Debug.Log("ACQUIRING TARGET");
                            FindTarget(c);
                        }
                        //If the character is in range, begin attacking
                        else if (current_Distance <= c.range)
                        {
                            c.CastUltimate();
                            c.Attack();
                            if (c.target.health <= 0)
                            {
                                grid[(int)c.target.grid_Position.x, (int)c.target.grid_Position.y].combat_Unit = null;
                                c.target.gameObject.SetActive(false);
                                c.target = null;
                            }
                        }
                    }
                }
            }
        }