Пример #1
0
 public void Enter(PlayerMachine.Data playerControll)
 {
     data = playerControll;
     //data.lineRender[1].gameObject.layer = 8;
     //data.lineRender[1].loop = true;
     DrawRange();
 }
Пример #2
0
 public void Enter(PlayerMachine.Data playerControll)
 {
     data                 = playerControll;
     data.targets         = new List <GameObject>();
     data.agent.isStopped = true;
     result               = null;
 }
Пример #3
0
 public void Enter(PlayerMachine.Data playerControll)
 {
     data      = playerControll;
     attacks   = new Attacks(data);
     isAnimate = false;
     data.agent.transform.LookAt(data.target);
 }
Пример #4
0
    public static List <Vector3> CurveRayHit(PlayerMachine.Data data, float distance, float range)
    {
        List <Vector3> Vectors    = new List <Vector3>();
        List <Vector3> VectorsRay = new List <Vector3>();
        Vector3        center     = (data.agent.transform.position + data.target) / 2;

        center.y = CalculateHeight(center, distance, range);

        for (float i = 0; i <= 1; i += 1f / 32)
        {
            Vector3 pos = Mathf.Pow(1 - i, 3) * data.agent.transform.position +
                          3 * Mathf.Pow(1 - i, 2) * i * center +
                          3 * (1 - i) * Mathf.Pow(i, 2) * center +
                          Mathf.Pow(i, 3) * data.target;
            Vectors.Add(pos);
        }
        if (Vectors.Count > 0)
        {
            VectorsRay.Add(Vectors[0]);
        }
        RaycastHit hit;

        for (int i = 0; i < Vectors.Count - 1; i++)
        {
            var vec1 = Vectors[i];
            var vec2 = Vectors[i + 1];
            if (Physics.Raycast(vec1, (vec2 - vec1).normalized, out hit, Vector3.Distance(vec1, vec2), 9))
            {
                VectorsRay.Add(hit.point);
                break;
            }
            VectorsRay.Add(vec2);
        }
        return(VectorsRay);
    }
Пример #5
0
 public void Enter(PlayerMachine.Data playerControll)
 {
     Debug.Log("Battle: CONTRATTACK!");
     data   = playerControll;
     target = playerControll.targets[0];
     result = null;
     Attacks();
 }
Пример #6
0
 public void Enter(PlayerMachine.Data playerControll)
 {
     data         = playerControll;
     result       = null;
     endAction    = false;
     data.targets = new List <GameObject>();
     hitTarget    = data.target;
 }
Пример #7
0
    static void RenderCurve(PlayerMachine.Data data, float range)
    {
        data.lineRender[0].startColor = Color.white;
        data.lineRender[0].endColor   = Color.white;
        var vectors = CurveRayHit(data, Vector3.Distance(data.agent.transform.position, data.target), range);

        data.lineRender[0].positionCount = vectors.Count;
        data.lineRender[0].SetPositions(vectors.ToArray());
    }
Пример #8
0
    static float DistanceCalculate(PlayerMachine.Data data)
    {
        float suma = 0;

        for (int i = 0; i < data.agent.path.corners.Length - 1; i++)
        {
            suma += Vector3.Distance(data.agent.path.corners[i], data.agent.path.corners[i + 1]);
        }
        suma *= MissionController.multiplyDistance;
        return((float)Math.Round(suma, 1));
    }
Пример #9
0
    static void RenderSimple(PlayerMachine.Data data)
    {
        data.lineRender[0].positionCount = 2;
        data.lineRender[0].startColor    = Color.white;
        data.lineRender[0].endColor      = Color.white;
        Vector3 vec1 = data.agent.transform.position;
        Vector3 vec2 = data.target;

        data.lineRender[0].SetPosition(0, vec1);
        data.lineRender[0].SetPosition(1, vec2);
    }
Пример #10
0
    public void Enter(PlayerMachine.Data playerControll)
    {
        result    = null;
        data      = playerControll;
        item      = (IConsume)data.character.Equipment.ItemSlots.Items[data.slotIndex].item;
        data.cost = 1;
        data.lineRender[0].enabled = false;
        data.lineRender[1].enabled = false;
        var gui = Object.FindObjectOfType <GUIControll>();

        gui.GUIEnabled.mission.Distance.SetActive(false);
    }
Пример #11
0
    public void Enter(PlayerMachine.Data playerControll)
    {
        data          = playerControll;
        data.distance = 0;

        var gui = Object.FindObjectOfType <GUIControll>();

        gui.GUIEnabled.mission.Distance.SetActive(false);

        SetWeapons();
        IPS_RangeFunction.DrawRange(data, GetMinRange(), data.agent.transform.position);
        AttackCost();
        result = null;
    }
Пример #12
0
 static void PointNone(PlayerMachine.Data data, float range)
 {
     if (Vector3.Distance(data.target, data.agent.transform.position) * MissionController.multiplyDistance <= range)
     {
         data.lineRender[0].enabled       = true;
         data.lineRender[0].positionCount = 2;
         data.lineRender[0].SetPosition(0, data.agent.transform.position);
         data.lineRender[0].SetPosition(1, data.target);
     }
     else
     {
         data.lineRender[0].enabled = false;
     }
 }
Пример #13
0
    public void Enter(PlayerMachine.Data playerControll)
    {
        result    = null;
        data      = playerControll;
        item      = (IThrow)data.character.Equipment.ItemSlots.Items[data.slotIndex].item;
        data.cost = 1;
        data.lineRender[0].enabled = false;
        data.lineRender[1].enabled = false;
        data.lineRender[2].enabled = false;
        var gui = Object.FindObjectOfType <GUIControll>();

        gui.GUIEnabled.mission.Distance.SetActive(false);
        ColorLine(Color.white);
        IPS_RangeFunction.DrawRange(data, item.Battle.range, data.agent.transform.position);
    }
Пример #14
0
 public static void MoveCost(PlayerMachine.Data data)
 {
     if (data.agent.isStopped)
     {
         data.distance = DistanceCalculate(data);
         if (data.distance <= data.freeMove)
         {
             data.cost = 0;
         }
         else
         {
             data.cost = 1 + (int)((data.distance - data.freeMove) / data.character.currentStats.Battle.move);
         }
     }
 }
Пример #15
0
 public Attack(PlayerMachine.Data _data, int _index)
 {
     index        = _index;
     data         = _data;
     targetAi     = null;
     targetPlayer = null;
     if (data.targets[0].TryGetComponent(out HolderDataEnemy enemy))
     {
         targetAi = enemy;
     }
     if (data.targets[0].TryGetComponent(out HolderDataCharacter character))
     {
         targetPlayer = character;
     }
     SetTarget();
     SetBools();
 }
Пример #16
0
 public void Enter(PlayerMachine.Data playerControll)
 {
     data = playerControll;
     gui  = Object.FindObjectOfType <GUIControll>();
     if (gui.GUIEnabled.mission.Equipment.activeSelf == true)
     {
         isExit = true;
     }
     else
     {
         isExit = false;
     }
     gui.GUIEnabled.mission.Equipment.SetActive(true);
     gui.GUIEnabled.mission.Equipment.GetComponent <EquipmentPanel>().Enter(data.character);
     gui.GUIEnabled.mission.Equipment.GetComponent <EquipmentPanel>().SetPoints(data.points);
     data.lineRender[0].enabled = false;
 }
Пример #17
0
    static void PointCurve(PlayerMachine.Data data, float range)
    {
        List <Vector3> Vectors    = new List <Vector3>();
        List <Vector3> VectorsRay = new List <Vector3>();
        float          distance   = Vector3.Distance(data.target, data.agent.transform.position);

        if (distance * MissionController.multiplyDistance <= range)
        {
            Vector3 center = (data.agent.transform.position + data.target) / 2;
            center.y = CalculateHeight(center, distance * MissionController.multiplyDistance, range);
            for (float i = 0; i <= 1; i += 1f / 32)
            {
                Vector3 pos = Mathf.Pow(1 - i, 3) * data.agent.transform.position +
                              3 * Mathf.Pow(1 - i, 2) * i * center +
                              3 * (1 - i) * Mathf.Pow(i, 2) * center +
                              Mathf.Pow(i, 3) * data.target;
                Vectors.Add(pos);
            }
            if (Vectors.Count > 0)
            {
                VectorsRay.Add(Vectors[0]);
            }
            for (int i = 0; i < Vectors.Count - 1; i++)
            {
                var        vec1 = Vectors[i];
                var        vec2 = Vectors[i + 1];
                RaycastHit hit;
                if (Physics.Raycast(vec1, (vec2 - vec1).normalized, out hit, Vector3.Distance(vec1, vec2), 9))
                {
                    VectorsRay.Add(hit.point);
                    break;
                }
                else
                {
                    VectorsRay.Add(vec2);
                }
            }
            data.lineRender[0].enabled       = true;
            data.lineRender[0].positionCount = VectorsRay.Count;
            data.lineRender[0].SetPositions(VectorsRay.ToArray());
        }
        else
        {
            data.lineRender[0].enabled = false;
        }
    }
Пример #18
0
    public static void PointRender(PlayerMachine.Data data, float range, MissileFlight missileFlight)
    {
        switch (missileFlight)
        {
        case MissileFlight.curve:
            PointCurve(data, range);
            break;

        case MissileFlight.none:
            PointNone(data, range);
            break;

        case MissileFlight.simply:
            PointSimple(data, range);
            break;
        }
    }
Пример #19
0
 static void PointSimple(PlayerMachine.Data data, float range)
 {
     if (Vector3.Distance(data.target, data.agent.transform.position) * MissionController.multiplyDistance <= range)
     {
         RaycastHit hit;
         if (Physics.Raycast(data.agent.transform.position, (data.target - data.agent.transform.position).normalized, out hit, range, 9))
         {
             data.target = hit.point;
         }
         data.lineRender[0].enabled       = true;
         data.lineRender[0].positionCount = 2;
         data.lineRender[0].SetPosition(0, data.agent.transform.position);
         data.lineRender[0].SetPosition(1, data.target);
     }
     else
     {
         data.lineRender[0].enabled = false;
     }
 }
Пример #20
0
        public Attacks(PlayerMachine.Data data)
        {
            attacks = new List <Attack>();
            switch (data.slotIndex)
            {
            case 0:
                attacks.Add(new Attack(data, 0));
                break;

            case 1:
                attacks.Add(new Attack(data, 1));
                break;

            case 2:
                attacks.Add(new Attack(data, 2));
                break;

            case 3:
                attacks.Add(new Attack(data, 1));
                attacks.Add(new Attack(data, 2));
                break;
            }
        }
Пример #21
0
    public static void DrawRange(PlayerMachine.Data data, float range, Vector3 position)
    {
        List <Vector3> Vectors = new List <Vector3>();
        float          scale   = 0.02f;
        float          Range   = range / MissionController.multiplyDistance;

        for (float i = 0; i < 2 * Mathf.PI; i += scale)
        {
            float      x      = Range * Mathf.Cos(i) + position.x;
            float      z      = Range * Mathf.Sin(i) + position.z;
            Vector3    pos    = new Vector3(x, position.y - 1f, z);
            Vector3    result = pos;
            RaycastHit hit;
            if (Physics.Raycast(result, (-1) * Vector3.up, out hit, 1000f, 0))
            {
                result = hit.point;
            }
            result.y += 0.05f;
            Vectors.Add(result);
        }
        data.lineRender[1].positionCount = Vectors.Count;
        data.lineRender[1].SetPositions(Vectors.ToArray());
        data.lineRender[1].enabled = true;
    }
Пример #22
0
    public static void PathRender(PlayerMachine.Data data, PathRenderType type)
    {
        if (data.agent.hasPath)
        {
            if (data.agent.isStopped)
            {
                if (data.points >= data.cost)
                {
                    switch (type)
                    {
                    case PathRenderType.Move:
                        data.lineRender[0].startColor = Color.blue;
                        data.lineRender[0].endColor   = Color.blue;
                        break;

                    case PathRenderType.Move_Attack:
                        data.lineRender[0].startColor = Color.yellow;
                        data.lineRender[0].endColor   = Color.yellow;
                        break;
                    }
                }
                else
                {
                    data.lineRender[0].startColor = Color.red;
                    data.lineRender[0].endColor   = Color.red;
                }
            }
            data.lineRender[0].positionCount = data.agent.path.corners.Length;
            data.lineRender[0].SetPositions(data.agent.path.corners);
            data.lineRender[0].enabled = true;
        }
        else
        {
            data.lineRender[0].enabled = false;
        }
    }
Пример #23
0
    public void Enter(PlayerMachine.Data playerControll)
    {
        data = playerControll;
        Debug.Log("Reload");
        switch (data.slotIndex)
        {
        case 1:
            ((IWeapon)data.character.Equipment.WeaponsSlot[0].Right[0].item).Ammunition.Amount =
                ((IWeapon)data.character.Equipment.WeaponsSlot[0].Right[0].item).Ammunition.Capacity;
            break;

        case 2:
            ((IWeapon)data.character.Equipment.WeaponsSlot[0].Left[0].item).Ammunition.Amount =
                ((IWeapon)data.character.Equipment.WeaponsSlot[0].Left[0].item).Ammunition.Capacity;
            break;

        case 3:
            ((IWeapon)data.character.Equipment.WeaponsSlot[0].Right[0].item).Ammunition.Amount =
                ((IWeapon)data.character.Equipment.WeaponsSlot[0].Right[0].item).Ammunition.Capacity;
            ((IWeapon)data.character.Equipment.WeaponsSlot[0].Left[0].item).Ammunition.Amount =
                ((IWeapon)data.character.Equipment.WeaponsSlot[0].Left[0].item).Ammunition.Capacity;
            break;
        }
    }
Пример #24
0
 public void Enter(PlayerMachine.Data playerControll)
 {
     throw new NotImplementedException();
 }
Пример #25
0
    public static void PathRenderAttack(PlayerMachine.Data data, Weapons weapons)
    {
        switch (data.slotIndex)
        {
        case 0:
            RenderNone(data);
            break;

        case 1:
            switch (weapons.w1.missileFlight)
            {
            case MissileFlight.curve:
                RenderCurve(data, weapons.w1.range);
                break;

            case MissileFlight.none:
                RenderNone(data);
                break;

            case MissileFlight.simply:
                RenderSimple(data);
                break;
            }
            break;

        case 2:
            switch (weapons.w2.missileFlight)
            {
            case MissileFlight.curve:
                RenderCurve(data, weapons.w2.range);
                break;

            case MissileFlight.none:
                RenderNone(data);
                break;

            case MissileFlight.simply:
                RenderSimple(data);
                break;
            }
            break;

        case 3:
            switch (weapons.w1.missileFlight)
            {
            case MissileFlight.curve:
                RenderCurve(data, weapons.w1.range);
                break;

            case MissileFlight.none:
                RenderNone(data);
                break;

            case MissileFlight.simply:
                RenderSimple(data);
                break;
            }
            break;
        }
        if (data.points < data.cost)
        {
            data.lineRender[0].enabled = false;
        }
        else
        {
            data.lineRender[0].enabled = true;
        }
    }