Beispiel #1
0
        public Data()
        {
            isEndTurn  = false;
            target     = new Vector3();
            lineRender = MissionController.Lines;
            agent      = MissionController.Characters[MissionController.Index].GetComponent <NavMeshAgent>();

            character = agent.GetComponent <HolderDataCharacter>().GetCharacter();
            points    = character.currentStats.Battle.actionPoint;

            targets = new List <GameObject>();

            agent.enabled   = true;
            agent.isStopped = true;

            weapons = new IPS_Functions.Weapons(character);

            slotIndex = 0;
        }
Beispiel #2
0
    void DrawRange()
    {
        Vectors = new List <Vector3>();
        IPS_Functions.Weapons weapons = data.weapons;
        float Range = weapons.HighRange() / MissionController.multiplyDistance;

        for (float i = 0; i < 2 * Mathf.PI; i += scale)
        {
            float      x      = Range * Mathf.Cos(i) + data.agent.transform.position.x;
            float      z      = Range * Mathf.Sin(i) + data.agent.transform.position.z;
            Vector3    pos    = new Vector3(x, data.agent.transform.position.y - 1f, z);
            Vector3    result = pos;
            RaycastHit hit;
            if (Physics.Raycast(result, (-1) * data.agent.transform.up, out hit, 1000f, 0))
            {
                result    = hit.point;
                result.y += 0.01f;
            }
            Vectors.Add(result);
        }
        data.lineRender[1].positionCount = Vectors.Count;
        data.lineRender[1].SetPositions(Vectors.ToArray());
        data.lineRender[1].enabled = true;
    }
Beispiel #3
0
    void WeaponInRange()
    {
        float posDistance = Vector3.Distance(data.target, data.agent.transform.position);

        IPS_Functions.Weapons weapons = data.weapons;
        float maxRange = weapons.HighRange();

        canAttack = true;

        // 0 - brak akcji, 1 - atak, 2 - podejście i atak
        int[] w = new int[3];
        data.slotIndex = 0;
        if (weapons.w1 != null && weapons.w1.canUse)
        {
            switch (weapons.w1.isWeapon)
            {
            case 1:
                w[1] = NoneRayHit(posDistance, weapons.w1.range);
                break;

            case 2:
                switch (weapons.w1.missileFlight)
                {
                case MissileFlight.curve:
                    w[1] = CurveRayHit(posDistance, weapons.w1.range);
                    break;

                case MissileFlight.simply:
                    w[1] = SimplyRayHit(posDistance, weapons.w1.range);
                    break;
                }
                break;
            }
        }
        if (weapons.w2 != null && weapons.w2.canUse)
        {
            Debug.Log(weapons.w2.canUse + " " + weapons.w2.isWeapon + " " + weapons.w2.missileFlight);
            switch (weapons.w2.isWeapon)
            {
            case 1:
                w[2] = NoneRayHit(posDistance, weapons.w2.range);
                break;

            case 2:
                switch (weapons.w2.missileFlight)
                {
                case MissileFlight.curve:
                    w[2] = CurveRayHit(posDistance, weapons.w2.range);
                    break;

                case MissileFlight.simply:
                    w[2] = SimplyRayHit(posDistance, weapons.w2.range);
                    break;
                }
                break;
            }
        }
        if (weapons.fist.canUse)
        {
            w[0] = NoneRayHit(posDistance, weapons.fist.range);
        }
        switch (w[1])
        {
        case 0:
            break;

        case 1:
            data.slotIndex += 1;
            break;

        case 2:
            if (w[2] != 1)
            {
                data.slotIndex += 1;
            }
            break;
        }
        switch (w[2])
        {
        case 0:
            break;

        case 1:
            data.slotIndex += 2;
            break;

        case 2:
            if (w[1] != 1)
            {
                data.slotIndex += 2;
            }
            break;
        }
        if (w[0] == 0 && data.slotIndex == 0)
        {
            data.slotIndex = -1;
        }

        Debug.Log("w0: " + w[0] + " w1: " + w[1] + " w2: " + w[2]);

        if (w.Count(x => x == 1) > 0)
        {
            ResetPath();
            IPS_Functions.PathRenderAttack(data, weapons);
        }
        else
        {
            if (w.Count(x => x == 2) > 0)
            {
                IPS_Functions.PathRender(data, IPS_Functions.PathRenderType.Move_Attack);
                if (weapons.DistanceAttack())
                {
                    canAttack = false;
                }
                else
                {
                    data.agent.SetDestination(hitTarget);
                }
            }
            else
            {
                ResetPath();
                canAttack = false;
            }
        }
        IPS_Functions.MoveCost(data);
        AttackCost();
    }