예제 #1
0
 public IAllyUnitState CheckChangeState(AllyUnit unit, PlayManager environment)
 {
     if (unit.GetPointTarget().HasValue)
     {
         return(new ClosestToPointTargetingAllyUnitState());
     }
     return(null);
 }
예제 #2
0
 public IAllyUnitState CheckChangeState(AllyUnit unit, PlayManager environment)
 {
     if (Vector3.Distance(unit.GetPositionToGo(), unit.transform.position) < unit.GetRadiusStopPosition())
     {
         return(new IdleAllyUnitState());
     }
     return(null);
 }
예제 #3
0
    public IAllyUnitState CheckChangeState(AllyUnit unit, PlayManager environment)
    {
        if (Vector3.Distance(unit.GetPositionToGo(), unit.transform.position) > unit.GetRadiusStopPosition())
        {
            return(new MovementAllyUnitState());
        }

        if (unit.GetUnitTarget() != null)
        {
            return(new ShootingAllyUnitState());
        }
        return(null);
    }
예제 #4
0
 public void Update(AllyUnit unit, PlayManager environment)
 {
     if (shootTime > unit.fireRate)
     {
         shootTime = 0;
         unit.Shoot();
         //Instantiate(_bulletPrefab, transform.position, transform.rotation);
     }
     else
     {
         shootTime += Time.deltaTime;
     }
     return;
 }
예제 #5
0
    private void CreateSpawnButton(int index, AllyUnit unit)
    {
        GameObject gameObject  = new GameObject("Unit" + index);
        GameObject gameObject1 = new GameObject("Cost");

        gameObject.transform.SetParent(SpawnCharacter);
        gameObject1.transform.SetParent(gameObject.transform);

        Button      button      = gameObject.AddComponent <Button>();
        Image       image       = gameObject.AddComponent <Image>();
        HoldonEvent holdonEvent = gameObject.AddComponent <HoldonEvent>();
        CoolDown    coolDown    = gameObject.AddComponent <CoolDown>();
        Text        costText    = gameObject1.AddComponent <Text>();

        image.rectTransform.sizeDelta     = new Vector2(150, 150);
        image.rectTransform.localPosition = new Vector3(-860 + 160 * index, 0, 0);
        image.rectTransform.localScale    = new Vector3(-1, 1, 1);

        costText.rectTransform.sizeDelta     = new Vector2(150, 40);
        costText.rectTransform.localPosition = new Vector3(0, -80);
        costText.rectTransform.localScale    = new Vector3(-1, 1, 1);
        costText.resizeTextForBestFit        = true;
        costText.resizeTextMaxSize           = 300;
        costText.resizeTextMinSize           = 14;
        costText.font      = font;
        costText.alignment = TextAnchor.MiddleCenter;
        costText.text      = ((int)EnumTransporter.AllyUnitToECost(unit)).ToString();
        costText.color     = Color.yellow;

        image.sprite        = CharacterSprites[(int)unit];
        image.type          = Image.Type.Filled;
        image.fillMethod    = Image.FillMethod.Radial360;
        image.fillOrigin    = 0;
        image.fillAmount    = 1;
        image.fillClockwise = true;

        holdonEvent.CharacterNum    = (int)unit;
        holdonEvent.CoolTime        = coolDown;
        holdonEvent.createCharacter = this;

        coolDown.CostText = costText;
        coolDown.Image    = image;
        coolDown.Tier     = EnumTransporter.AllyUnitToETier(unit);
        coolDown.Cost     = EnumTransporter.AllyUnitToECost(unit);
        coolDown.CoolOver = true;
    }
예제 #6
0
    public static ETier AllyUnitToETier(AllyUnit unit)
    {
        int a = (int)unit;

        if (a >= 0 && a <= 10)
        {
            return(ETier.Tier1);
        }
        else if (a >= 11 && a <= 16)
        {
            return(ETier.Tier2);
        }
        else if (a >= 17 && a <= 24)
        {
            return(ETier.Tier3);
        }

        return(ETier.None);
    }
예제 #7
0
    public void Update(AllyUnit unit, PlayManager environment)
    {
        if (unit.GetPointTarget().HasValue)
        {
            return;
        }
        float minDistance = Mathf.Infinity;
        Unit  target      = null;

        for (int i = 0; i < environment.enemyUnits.Count; i++)
        {
            float distance;
            distance = Vector3.Distance(environment.enemyUnits[i].transform.position, unit.transform.position);
            if (distance < minDistance)
            {
                minDistance = distance;
                target      = environment.enemyUnits[i];
            }
        }
        unit.SetTarget(target);
    }
예제 #8
0
 public void Update(AllyUnit unit, PlayManager environment)
 {
     return;
 }
예제 #9
0
 public void Update(AllyUnit unit, PlayManager environment)
 {
     unit.transform.Translate(Vector3.Normalize(new Vector3(unit.GetPositionToGo().x - unit.transform.position.x, unit.GetPositionToGo().y - unit.transform.position.y, 0)) * unit.GetSpeed() * Time.deltaTime, Space.World);
 }
예제 #10
0
    private void CheckSelectUnit()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            clickDown = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 9f));
        }
        if (Input.GetKey(KeyCode.Mouse0))
        {
            massiveSelectionCurrentTime += Time.deltaTime;
            if (massiveSelectionCurrentTime > massiveSelectionTimeThreshold)
            {
                isMassiveSelection = true;
                clickUp            = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 9f));
                unitsSelected.ForEach(unitSelected => {
                    unitSelected.SelectUnit(false);
                });
                unitsSelected = new List <AllyUnit>();
                unitTarget    = null;
                pointTarget   = null;
            }
        }

        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            unitTarget         = null;
            pointTarget        = null;
            isMassiveSelection = false;
            clickUp            = null;
            clickDown          = null;
            LineRenderer line = GetComponent <LineRenderer>();
            line.positionCount = 0;
            line.SetPositions(new Vector3[0]);

            if (massiveSelectionCurrentTime < massiveSelectionTimeThreshold)
            {
                unitsSelected.ForEach(unitSelected => {
                    unitSelected.SelectUnit(false);
                });
                unitsSelected = new List <AllyUnit>();
                massiveSelectionCurrentTime = 0f;

                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                Physics.Raycast(ray, out hit);

                if (hit.collider && hit.collider.tag == "AllySelection")
                {
                    //unitsSelected = new List<Unit>();
                    AllyUnit unit = (AllyUnit)hit.collider.gameObject.GetComponent <UnitSelection>().GetUnit();
                    //unitSelected = unit;
                    //unitsSelected = new List<Unit>();
                    unitsSelected.Add(unit);
                    unit.SelectUnit(true);
                }
                if (hit.collider && hit.collider.tag == "AlienSelection")
                {
                    //
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Mouse1))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            Physics.Raycast(ray, out hit);
            if (hit.collider && hit.collider.tag == "AlienSelection")
            {
                Unit unit = hit.collider.gameObject.GetComponent <UnitSelection>().GetUnit();

                unitsSelected.ForEach(unitSelected => {
                    unitSelected.SetTarget(unit);
                    //unitSelected.unitTarget = unit;
                    unitSelected.SetPointTarget(null);
                });
            }
            else
            {
                Vector3 positionSelected = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 9f));

                if (positionSelected.y < limitLineTopAllyUnit && positionSelected.y > limitLineBottomAllyUnit)
                {
                    unitsSelected.ForEach(unitSelected => {
                        unitSelected.SetPositionToGo(positionSelected);
                    });
                }
                else
                {
                    unitsSelected.ForEach(unitSelected => {
                        unitSelected.SetTarget(null);
                        unitSelected.SetPointTarget(positionSelected);
                    });
                }
            }
        }
    }
예제 #11
0
    public static ECost AllyUnitToECost(AllyUnit unit)
    {
        switch (unit)
        {
        case AllyUnit.전사:
        {
            return(ECost.Warrior);
        }

        case AllyUnit.검사:
        {
            return(ECost.SSanggumsa);
        }

        case AllyUnit.무사:
        {
            return(ECost.Musa);
        }

        case AllyUnit.창병:
        {
            return(ECost.ChangBeong);
        }

        case AllyUnit.장창병:
        {
            return(ECost.JangChangBeong);
        }

        case AllyUnit.투창병:
        {
            return(ECost.TuChangBeong);
        }

        case AllyUnit.기마병:
        {
            return(ECost.GiMaBeong);
        }

        case AllyUnit.경기병:
        {
            return(ECost.GeongGiBeong);
        }

        case AllyUnit.기사:
        {
            return(ECost.GiSa);
        }

        case AllyUnit.해머병:
        {
            return(ECost.HammerBeong);
        }

        case AllyUnit.철퇴병:
        {
            return(ECost.凸TeauBeong);
        }

        case AllyUnit.방패병:
        {
            return(ECost.BangPeBeong);
        }

        case AllyUnit.기갑병:
        {
            return(ECost.GiGabBeong);
        }

        case AllyUnit.사제:
        {
            return(ECost.Trash);
        }

        case AllyUnit.고위사제:
        {
            return(ECost.GoWiiTrash);
        }

        case AllyUnit.암살자:
        {
            return(ECost.AmSalJa);
        }

        case AllyUnit.어쎄신:
        {
            return(ECost.Assesin);
        }

        case AllyUnit.귀족:
        {
            return(ECost.GuiJok);
        }

        case AllyUnit.국왕:
        {
            return(ECost.GukWang);
        }

        case AllyUnit.성기사:
        {
            return(ECost.SeongGiSa);
        }

        case AllyUnit.영웅:
        {
            return(ECost.AU);
        }

        case AllyUnit.대장군:
        {
            return(ECost.DaeJangGun);
        }

        case AllyUnit.총사령관:
        {
            return(ECost.GunSaRyeongGuan);
        }
        }
        return(ECost.None);
    }