Beispiel #1
0
        public void Do()
        {
            var metaInput    = InputParent.GetMetaInput(InputToPublish);
            var newMetaInput = metaInput.Clone();

            newMetaInput.Name = _newName;

            var addInputCommand = new AddInputCommand(CompositionOperator, newMetaInput);

            addInputCommand.Do();

            var opPartToUpdate    = CompositionOperator.Inputs[CompositionOperator.Inputs.Count - 1];
            var func              = InputToPublish.Func.Clone() as Utilities.ValueFunction;
            var updateFuncCommand = new UpdateOperatorPartValueFunctionCommand(opPartToUpdate, func.Value);

            updateFuncCommand.Do();

            var connection = new MetaConnection(Guid.Empty, newMetaInput.ID, InputToPublish.Parent.ID, metaInput.ID);
            var insertConnectionCommand = new InsertConnectionCommand(CompositionOperator.Definition, connection, 0);

            insertConnectionCommand.Do();

            _commands.Clear();
            _commands.AddRange(new ICommand[] { addInputCommand, updateFuncCommand, insertConnectionCommand });
        }
Beispiel #2
0
    public void Summon()
    {
        if (zombies.Count >= states.rpg.level + 5)
        {
            zombies[0].states.Hurt(zombies[0].states.rpg.health.max);
        }


        Vector3 position = transform.position + transform.forward;

        ProduceEffects(position);

        PlayerMinionScript temp =
            ObjectPool.Instance.GetObject(
                "Ally_Flesh_Golem(Clone)",
                position,
                transform.rotation)
            .GetComponent <PlayerMinionScript>();

        InputParent ip = states.GetComponent <InputParent>();

        temp.states.Revive(states.rpg.level);
        temp.SubscribeToCommander(ip);

        zombies.Add(temp);
        ip.UpdateStatsText();
    }
    void GetNextTarget(string side)
    {
        canSwitchTarget = false;
        StartCoroutine(SnapifyChangeTarget());


        Collider[] colliders = Physics.OverlapSphere(transform.position, lockonDist, 1 << 11);
        if (colliders.Length == 1)
        {
            return;
        }

        InputParent currentEnemyTarget = states.enemyTarget;

        float smallestAngle = 180;

        for (int i = 0; i < colliders.Length; i++)
        {
            NPCInput enemy = colliders[i].GetComponent <NPCInput>();

            if (enemy != null)
            {
                if (Physics.Linecast(states.aem.head.position,
                                     enemy.states.aem.body.position,
                                     1 << 0))
                {
                    continue;
                }

                if (enemy == currentEnemyTarget)
                {
                    continue;
                }

                Vector3 to    = colliders[i].transform.position - mainCam.transform.position;
                float   angle = Vector3.SignedAngle(mainCam.transform.forward, to, mainCam.transform.up);

                if (side == "left" && angle > 0)
                {
                    continue;
                }
                if (side == "right" && angle < 0)
                {
                    continue;
                }


                if (Mathf.Abs(angle) < smallestAngle)
                {
                    states.LockonOn(enemy);
                    smallestAngle = Mathf.Abs(angle);
                }
            }
        }
        if (states.enemyTarget == null)
        {
            states.LockOff();
        }
    }
Beispiel #4
0
    public void LockonOn(InputParent enemy)
    {
        OnFillUpEnemyTarget(enemy);

        lockon        = true;
        enemyTarget   = enemy;
        lookTransform = enemyTarget.states.aem.body;
    }
Beispiel #5
0
    public void LockOff()
    {
        lockon = false;
        if (enemyTarget == null)
        {
            return;
        }


        enemyTarget   = null;
        lookTransform = null;


        OnEmptyEnemyTarget();
    }
Beispiel #6
0
    void GetEnemyTarget()
    {
        Collider[] colliders = Physics.OverlapSphere(transform.position, lockonDist, 1 << hostileLayer);
        if (colliders.Length == 0)
        {
            return;
        }

        for (int i = 0; i < colliders.Length; i++)
        {
            InputParent enemy = colliders[i].GetComponent <InputParent>();

            if (enemy != null)
            {
                Debug.DrawLine(states.aem.head.position,
                               enemy.states.aem.body.position - states.aem.body.forward * (enemy.states.capsule.radius + 0.05f));
                if (Physics.Linecast(states.aem.body.position,
                                     enemy.states.aem.body.position, // - states.aem.body.forward * (enemy.states.capsule.radius + 0.05f),
                                     1 << 0                          //| 1 << states.aem.friendlyLayer//1 << 10 | 1 << 11
                                     ))
                {
                    continue;
                }

                //Debug.Log("AHA!");


                if (states.enemyTarget == null)
                {
                    states.LockonOn(enemy);
                }
                else
                {
                    Vector3 to       = colliders[i].transform.position - transform.position;
                    float   newAngle = Vector3.SignedAngle(transform.forward, to, transform.up);

                    to = states.enemyTarget.transform.position - transform.position;
                    float oldAngle = Vector3.SignedAngle(transform.forward, to, transform.up);

                    if (Mathf.Abs(newAngle) < Mathf.Abs(oldAngle))
                    {
                        states.LockonOn(enemy);
                    }
                }
            }
        }
    }
    void HandleLockon()
    {
        if (enemyTarget != null)
        {
            enemyTarget.states.engagedBy = this;

            float enemyTargetDistance = Vector3.Distance(enemyTarget.transform.position, transform.position);
            if (enemyTargetDistance > maxEnemyTargetDistance || !lockon)
            {
                enemyTarget.states.engagedBy = null;
                enemyTarget = null;
            }
        }

        if (enemyTarget == null)
        {
            lockon = false;
        }
    }
    public void HurtPeople(GameObject collider)
    {
        if (collider.layer != 8 && collider.layer != friendlyLayer)
        {
            InputParent ip = collider.GetComponent <InputParent>();
            if (ip != null)
            {
                ModifyHostileStats(ip);
            }
            else
            {
                particle = "Sparks(Clone)";
            }

            if (particle != null)
            {
                ObjectPool.Instance.GetObject(particle, transform.position, Quaternion.LookRotation(-transform.forward));
                particle = null;
            }
        }
    }
Beispiel #9
0
 private void States_OnFillUpEnemyTarget(InputParent obj)
 {
     path.Clear();
     states.walk = false;
 }
    void ModifyHostileStats(InputParent ip)
    {
        float totalDamage = damage - ip.states.rpg.GetDefence();

        if (totalDamage < 0)
        {
            totalDamage = 0;
        }

        bool hasHitShield = false;

        EquippableShield equippableShield = ip.states.rpg.currentShield;

        if (equippableShield != null)
        {
            if (equippableShield.shieldScript.gameObject.activeSelf)
            {
                float angle = Vector3.SignedAngle(ip.transform.forward, ownerForward, Vector3.up);
                //Debug.Log(angle);
                if (angle > 90 || angle < -90)
                {
                    //isHit = true;
                    hasHitShield = true;
                    particle     = "Blue Sparks(Clone)";
                    if (equippableShield.shieldScript.parryWindow)
                    {
                        if (wielder != null)
                        {
                            wielder.animator.CrossFade("Stagger", 0.15f);
                        }
                    }
                    else
                    {
                        ip.states.rpg.stamina.ModifyCur(-totalDamage * 1.75f);
                    }
                }
            }
        }


        if (!ip.states.isDodge && !hasHitShield /* && !isHit*/)
        {
            ip.states.Hurt(totalDamage);

            particle = totalDamage == 0 ? "Blue Sparks(Clone)" : "Blood(Clone)";

            if (totalDamage == 0)
            {
                if (wielder != null)
                {
                    wielder.animator.CrossFade("Stagger", 0.15f);
                }
            }

            if (ip.ui != null)
            {
                if (!ip.ui.activeSelf)
                {
                    ip.StartCoroutine(ip.ShowUI());
                }
            }
        }
    }
 private void States_OnFillUpEnemyTarget(InputParent enemy)
 {
     cameraManager.enemyTarget = enemy;
 }
Beispiel #12
0
 public void SubscribeToCommander(InputParent ip)
 {
     commander = ip;
     goThere   = commander.states.aem.commandCursor;
     commander.states.aem.OnCommand += Aem_OnCommand;
 }