Exemplo n.º 1
0
    void DrawEnergy(EnergyEmitter emitter)
    {
        var        receivedEnergy = emitter.TransmitEnergy();
        EnergyType energyType     = emitter.GetEnergyType();

        energyReceiver.AddEnergy(receivedEnergy, energyType);
        heatEffects.AddEnergy(receivedEnergy, energyType);
    }
Exemplo n.º 2
0
        // private void DrainEnergy(float energy)
        // {
        //     if (this.currentTarget == null)
        //     {
        //         return;
        //     }

        //     Actor targetMinion = this.currentTarget.GetComponentInParent<Actor>();
        //     if (targetMinion == null)
        //     {
        //         return;
        //     }

        //     if (targetMinion.Energy.CurrentVal >= energy && targetMinion.Energy.CurrentVal >= targetMinion.UsedEnergy.CurrentVal)
        //     {
        //         if (this.energyLine == null && this.drainLinePrefab != null)
        //         {
        //             this.energyLine = Instantiate(this.drainLinePrefab, Vector3.zero, Quaternion.identity) as GameObject;
        //             this.energyLine.transform.position = this.BeamStartPosition.transform.position;
        //             this.energyLine.transform.rotation = Quaternion.LookRotation(this.line.GetPosition(1) - this.line.GetPosition(0));
        //             float distance = Vector3.Distance(this.transform.position, this.currentTarget.position);
        //             this.energyLine.transform.localScale = Vector3.one * (distance / this.defaultEffectSize) * effectScale;
        //             Destroy(this.energyLine, 1.0f);
        //         }

        //         GenericScripts.Events.EventHandler.Instance.Raise(new UpdateStats()
        //         {
        //             Actor = this.CasterActor,
        //             Energy = new GenericScripts.Data.Stat()
        //             {
        //                 MaxVal = this.CasterActor.Energy.MaxVal,
        //                 CurrentVal = this.CasterActor.Energy.CurrentVal + energy
        //             }
        //         });

        //         GenericScripts.Events.EventHandler.Instance.Raise(new UpdateStats()
        //         {
        //             Actor = targetMinion,
        //             Energy = new GenericScripts.Data.Stat()
        //             {
        //                 MaxVal = targetMinion.Energy.MaxVal,
        //                 CurrentVal = targetMinion.Energy.CurrentVal - energy
        //             }
        //         });

        //         EnergyEmitter targetEmitter = targetMinion.GetComponent<EnergyEmitter>();
        //         MinionEnergyReturn targetTransfer = targetMinion.GetComponent<MinionEnergyReturn>();
        //         if (targetEmitter != null)
        //         {
        //             Destroy(targetEmitter);
        //         }

        //         if (targetTransfer != null)
        //         {
        //             Destroy(targetTransfer);
        //         }

        //         if (/*targetMinion.Energy.CurrentVal - targetMinion.UsedEnergy.CurrentVal <= 0 && */!targetMinion.Controlled)
        //         {
        //             GenericScripts.Events.EventHandler.Instance.Raise(new MinionDowngradeEvent()
        //             {
        //                 Minion = targetMinion
        //             });
        //             GenericScripts.Events.EventHandler.Instance.Raise(new CurrentMinionChangedEvent()
        //             {
        //                 minion = targetMinion
        //             });
        //         }
        //     }

        // }

        private void GiveEnergy(float energy)
        {
            if (this.currentTarget == null)
            {
                return;
            }

            Minion targetMinion = this.currentTarget.GetComponentInParent <Minion>();

            if (targetMinion == null)
            {
                return;
            }

            if (this.CasterActor.Energy.CurrentVal < energy /* ||
                                                             * targetMinion.Energy.CurrentVal + energy > targetMinion.Energy.MaxVal ||
                                                             * targetMinion.Energy.CurrentVal >= targetMinion.UsedEnergy.CurrentVal + this.lowestLimbCost*/)
            {
                return;
            }

            if (this.energyLine == null && this.giveLinePrefab != null)
            {
                this.energyLine = Instantiate(this.giveLinePrefab, Vector3.zero, Quaternion.identity) as GameObject;
                this.energyLine.transform.position = this.BeamStartPosition.transform.position;
                this.energyLine.transform.rotation = Quaternion.LookRotation(this.line.GetPosition(1) - this.line.GetPosition(0));
                float distance = Vector3.Distance(this.transform.position, this.currentTarget.position);
                this.energyLine.transform.localScale = Vector3.one * (distance / this.defaultEffectSize) * effectScale;
                Destroy(this.energyLine, 1.0f);
            }

            // GenericScripts.Events.EventHandler.Instance.Raise(new UpdateStats()
            // {
            //     Actor = this.CasterActor,
            //     Energy = new GenericScripts.Data.Stat()
            //     {
            //         MaxVal = this.CasterActor.Energy.MaxVal,
            //         CurrentVal = this.CasterActor.Energy.CurrentVal - energy
            //     }
            // });

            // GenericScripts.Events.EventHandler.Instance.Raise(new UpdateStats()
            // {
            //     Actor = targetMinion,
            //     Energy = new GenericScripts.Data.Stat()
            //     {
            //         MaxVal = targetMinion.Energy.MaxVal,
            //         CurrentVal = targetMinion.Energy.CurrentVal + energy
            //     }
            // });

            // GenericScripts.Events.EventHandler.Instance.Raise(new EnergyGainEvent()
            // {
            //     Actor = targetMinion,
            //     Initiator = this.CasterActor
            // });

            if (targetMinion.GetComponent <EnergyEmitter>() == null)
            {
                EnergyEmitter e = targetMinion.gameObject.AddComponent <EnergyEmitter>();
                e.SetupVariables(this.density, this.speed * 2, this.spread, this.finishRange, this.emitter);
            }

            // if (targetMinion.GetComponent<MinionEnergyReturn>() == null)
            // {
            //     targetMinion.gameObject.AddComponent<MinionEnergyReturn>();
            // }

            // if (targetMinion.Energy.CurrentVal - targetMinion.UsedEnergy.CurrentVal >= this.lowestLimbCost)
            // {
            GenericScripts.Events.EventHandler.Instance.Raise(new MinionUpgradeEvent()
            {
                Minion = targetMinion
            });
            GenericScripts.Events.EventHandler.Instance.Raise(new CurrentMinionChangedEvent()
            {
                minion          = targetMinion,
                currentMinionID = -1
            });
            // }
        }