Inheritance: MonoBehaviour
コード例 #1
0
    void lifeChangedFunc(Life pLife)
    {
        bool lIsOn = false; ;
        float lLifeRate = pLife.rate;
        if(minRange<=lLifeRate&&lLifeRate<=maxRange)
        {
            lIsOn = true;
        }
        if(isOn)
        {
            if(!lIsOn)
            {
                isOn = lIsOn;
                offRangeEvent();
            }
        }
        else
        {
            if (lIsOn)
            {
                isOn = lIsOn;
                onRangeEvent();
            }

        }
    }
コード例 #2
0
    IEnumerator Start()
    {
        if(Network.peerType== NetworkPeerType.Disconnected)
        {
            Destroy(this);
        }
        else
        {
            while(true)
            {
                if (transform.parent && transform.parent.GetComponent<StrongholdUpdate>())
                    break;
                yield return null;
            }
            var lParent = transform.parent;
            life = lParent.GetComponent<Life>();
            if(life.isAlive())
            {
                if (Network.isServer)
                {
                    var lParentNetview = lParent.networkView;
                    //preSysnState = lParentNetview.stateSynchronization;
                    //lParentNetview.stateSynchronization = NetworkStateSynchronization.Off;
                    lParentNetview.enabled = false;
                }
            }
            networkView.enabled = true;

        }
    }
コード例 #3
0
    //执行圆球范围的伤害,伤害随离中心距离增加而递减
    public static void impSphereAreaHarm(Vector3 pCenterPos, float pHarmRadius,float pMinRate,
        float pHarmValueInCentre, int pHarmLayerMask, canHarmFunc pCanHarmFunc,
        Life.HarmType pHarmType)
    {
        //现在用于存储有生命的物体,离爆炸点的最近距离
        Hashtable lInjuredLifeMinDistance = new Hashtable();
        Collider[] lColliderList = Physics.OverlapSphere(pCenterPos, pHarmRadius, pHarmLayerMask);
        //搜寻范围内的Life,并寻找最短距离
        foreach (Collider i in lColliderList)
        {

            //Trigger 也会被探测到
            if (i.isTrigger)
                continue;
            Life lLife = Life.getLifeFromTransform(i.transform);
            if (lLife)
            {
                //lLife.injure(harmValueInCentre);
                //获得物体离中心pCenterPos的最近距离
                Vector3 lClosestPoint = i.ClosestPointOnBounds(pCenterPos);
                float lDistance = Vector3.Distance(lClosestPoint, pCenterPos);

                //因为一个有Life的物体上,可能有多个Collider
                if (lInjuredLifeMinDistance.ContainsKey(lLife))
                {
                    float lObjectDistance = (float)lInjuredLifeMinDistance[lLife];
                    if (lObjectDistance > lDistance)
                    {
                        //相同Life时,若距离比之前获得的Collider物体小,则替换
                        //print(""+lInjuredLifeMinDistance[lLife]+">"+lDistance);
                        lInjuredLifeMinDistance[lLife] = lDistance;
                    }
                }
                else
                    lInjuredLifeMinDistance[lLife] = lDistance;
            }

        }

        //执行伤害
        foreach (System.Collections.DictionaryEntry lifeToDistance in lInjuredLifeMinDistance)
        {
            // The hit points we apply fall decrease with distance from the explosion point
            Life lLifeImp = (Life)lifeToDistance.Key;

            //判断是否可以执行伤害
            if(pCanHarmFunc(lLifeImp))
            {
                float lDistanceImp = (float)lifeToDistance.Value;
                float lHarmRange = Mathf.Lerp(pMinRate, 1f, 1.0f - Mathf.Clamp01(lDistanceImp / pHarmRadius));
                //print(lDistanceImp);
                //print(lHarmRange);
                //print(lHarmRange *harmValueInCentre );
                lLifeImp.injure((int)(lHarmRange * pHarmValueInCentre), pHarmType);

            }
        }

        //lInjuredLifeMinDistance.Clear();
    }
コード例 #4
0
 void Start()
 {
     if (Network.isClient)
         return;
     life = gameObject.GetComponentInChildren<Life>();
     life.addDieCallback(deadAction);
 }
コード例 #5
0
    public void createSphereAreaHarm(Life pLife)
    {
        GameObject lAreaHarm = (GameObject)GameObject.Instantiate(sphereAreaHarm.gameObject, pLife.transform.position, pLife.transform.rotation);

        SphereAreaHarm lSphereAreaHarm = lAreaHarm.GetComponent<SphereAreaHarm>();
        lSphereAreaHarm.setHarmLayerMask(adversaryLayerMask.value);
    }
コード例 #6
0
ファイル: E_bullet.cs プロジェクト: S-R-N/Shooting-Stream
	void Start () {
		/*
		pos=gameObject.transform.position;
		tpos = targetposition.gameObject.transform.position;
		*/
		life = GameObject.Find ("Lifeber").GetComponent<Life> ();
	}
コード例 #7
0
ファイル: Life.cs プロジェクト: ocoulson/UnityTuts
	void awake() {
		if (instance != null) {
			Destroy (gameObject);
		} else {
			GameObject.DontDestroyOnLoad(gameObject);
			instance = this;
			lives = 3;
		}
	}
コード例 #8
0
 // Use this for initialization
 void Start()
 {
     bar = renderer.material;
     tiling = bar.GetTextureScale("_MainTex").x;
     PlayerController = GameObject.FindGameObjectWithTag("PlayerController");
     if(PlayerController!=null)
         life = PlayerController.GetComponent<Life>();
     health = 1;
 }
コード例 #9
0
ファイル: BloodBar.cs プロジェクト: Seraphli/TheInsectersWar
 //void  Update (){
 //}
 public void UpdateBar(Life life)
 {
     float lFullBloodValue = life.getFullBloodValue();
     float lRate = life.getBloodValue() / lFullBloodValue;
     if (lRate < 0)
         SetRate(0);
     else
         SetRate(lRate);
 }
コード例 #10
0
 //在死亡的回调中使用
 void deadAction(Life p)
 {
     if ((!onlyInHost) || (!Network.isClient))
     {
         var lObject = (GameObject)Instantiate(objectToCreate,
             transform.position, transform.rotation);
         lObject.GetComponent<CharacterInfoObject>().characterInfo
             = characterInfoObject.characterInfo;
     }
 }
コード例 #11
0
ファイル: Boss.cs プロジェクト: DanielParra159/GGJ2016
	// Use this for initialization
	void Start () {
        shootsPool.Reset();
        animator = gameObject.GetComponentInChildren<Animator>();
        life = gameObject.GetComponent<Life>();
        life.registerOnDead(onDead);
        life.registerOnDamage(onDamage);
        hero = GameManager.instance.hero;

        unit = true;
	}
コード例 #12
0
    //在死亡的回调中使用
    void deadAction(Life p)
    {
        if (messageReceiver)
        {
            if (sendSelf)
                messageReceiver.SendMessage(methodName, this, SendMessageOptions.RequireReceiver);
            else
                messageReceiver.SendMessage(methodName, SendMessageOptions.RequireReceiver);

        }
    }
コード例 #13
0
 //FIXME_VAR_TYPE transform;
 //void Start()
 //{
 //    //GameObject lOwner  = transform.parent.gameObject;
 //    if (!owner)
 //        return;
 //    if (Network.peerType != NetworkPeerType.Disconnected && networkView.isMine)
 //    {
 //        networkView.RPC("RPCSetOwner", RPCMode.Others, owner.networkView.viewID);
 //        networkView.enabled = true;
 //    }
 //}
 public void setOwner(GameObject pOwner)
 {
     gameObject.name = "NS";
     transform.parent = pOwner.transform;
     transform.localPosition = Vector3.zero;
     owner = pOwner;
     hero = owner.GetComponentInChildren<Hero>();
     character = hero.getCharacter();
     actionCommandControl = owner.GetComponentInChildren<ActionCommandControl>();
     life = owner.GetComponent<Life>();
     soldierModelSmoothMove = owner.GetComponent<SoldierModelSmoothMove>();
 }
コード例 #14
0
ファイル: RPGCustomCharacter.cs プロジェクト: MRCulpo/RPGCore
 /// <summary>
 /// Contrutor sem parametro
 /// </summary>
 public RPGCustomCharacter()
 {
     this.name = "";
     this.typeClass = new Class();
     this.level = new ExperienceLevel();
     this.life = new Life();
     this.damage = new Damage();
     this.armor = new Armor();
     this.attributes = new Attributes();
     this.inventory = new Inventory();
     this.abilityManager = new AbilityManager();
     this.effects = new List<Effect>();
     this.level = new ExperienceLevel();
 }
コード例 #15
0
    public void RPCSetOwner(NetworkViewID pOwnerID)
    {
        GameObject lOwnerHeroObject = NetworkView.Find(pOwnerID).gameObject;

        gameObject.name = "NS";
        transform.parent = lOwnerHeroObject.transform;
        owner = lOwnerHeroObject;

        //-------------------------------------------
        Hero lHero = owner.GetComponentInChildren<Hero>();
        character = lHero.getCharacter();
        actionCommandControl = owner.GetComponentInChildren<ActionCommandControl>();
        life = owner.GetComponent<Life>();
    }
コード例 #16
0
        public QuestionsPage()
        {
            this.InitializeComponent();
            subject = new SubjectViewModel();
            correct_answer = new English();
            maths = new Maths();
            business = new Business();
            accounting = new Accounting();
            geography = new Geography();
            history = new History();
            life = new Life();
            physics = new Physics();
            time.Start();

        }
コード例 #17
0
 //在死亡的回调中使用
 void deadAction(Life p)
 {
     var lCharacterInfo = life.characterInfo;
     if (lCharacterInfo != null)
     {
         lCharacterInfo.purse.add(shootAward);
         var lLifeFlashManager = LifeFlashManager.Singleton;
         var lPos = (showNumPosition ? showNumPosition : transform).position;
         if (lCharacterInfo.belongToThePlayer)
             lLifeFlashManager.showAwardNumLabel(lPos, shootAward);
         else
             lLifeFlashManager.showAwardNumLabel(
                 lPos, shootAward, lCharacterInfo.player);
     }
 }
コード例 #18
0
    void destroyed(Life pLife)
    {
        if (GameScene.Singleton.playerInfo.race != race)
            return;
        if(bubble)
        {
            GameObject.Destroy(bubble.gameObject);
        }
        if (destroyedSound)
            zzBackgroudAudioPlayer.Singleton.play(destroyedSound);

        bubble = bubbleMessage.addBubble(destroyedBubblePrefab);
        bubble.transform.position = bubblePosition.position;
        bubble.bubblePosition = bubble.transform;
        ((zzGUIBubbleLayout)bubble.bubbleLayout).showTime = warningTimeLength;
    }
コード例 #19
0
ファイル: LifeFlash.cs プロジェクト: Seraphli/TheInsectersWar
 void bloodValueChanged(Life pLife)
 {
     var lCharacterInfo = pLife.characterInfo;
     var lLifeFlashManager = LifeFlashManager.Singleton;
     if (isPlayer)
     {
         playColorAnimation(lLifeFlashManager.selfAttackedColor);
     }
     else if(lCharacterInfo!=null
         && lCharacterInfo.race == PlayerInfo.playerRace)
     {
         if (lCharacterInfo.belongToThePlayer)
             playColorAnimation( lLifeFlashManager.attackedBySelfColor );
         else
             playColorAnimation( lLifeFlashManager.attackedByTeammateColor );
     }
 }
コード例 #20
0
 void bloodValueChanged(Life pLife)
 {
     if (pLife.bloodValue < lastBloodValue
         && GameScene.Singleton.playerInfo.race == race)
     {
         if (!bubble)
         {
             if (attackedSound)
                 zzBackgroudAudioPlayer.Singleton.play(attackedSound);
             bubble = createBubble(attackedBubblePrefab);
             ((zzGUIBubbleLayout)bubble.bubbleLayout)
                 .showTime = warningTimeLength;
         }
         ((zzGUIBubbleLayout)bubble.bubbleLayout)
             .timePostion = 0f;
     }
     lastBloodValue = pLife.bloodValue;
 }
コード例 #21
0
ファイル: Enemy.cs プロジェクト: DanielParra159/GGJ2016
	// Use this for initialization
	void Start () {
		myTransform = transform;
		target = GameManager.instance.hero.transform;
		agent = GetComponent<NavMeshAgent> ();

		// Disparos
		if (!isSeeker) {
			shootsPool.Reset ();
			agent.Stop ();
		} else {
//			agent.updatePosition = true;
			agent.updateRotation = false;
		}

        life = gameObject.GetComponent<Life>();
        life.registerOnDead(onDead);
        life.registerOnDamage(onDamage);
	}
コード例 #22
0
	public void Setup(GameObject item) {
		player = (Player) gameObject.GetComponentInParent<Player>();
		monster = (Monster) gameObject.GetComponentInParent<Monster>();

		this.item = item;
		if (monster != null) {
			this.item = item.GetComponent<Monster>().iaToFollow;
			monsterRigidBody = this.item.GetComponent<Rigidbody2D>();
			monsterVehicle = monsterRigidBody.gameObject.GetComponent<AutonomousVehicle2D>();
			monsterAttack = monster.GetComponentInChildren<Attack>();
			life = monster.GetLife();
		} else if (player != null) {
			playerRigidBody = item.GetComponent<Rigidbody2D>();
			playerMovement = player.GetComponent<PlayerMovement>();
			playerAttack = player.GetComponentInChildren<Attack>();
			life = player.GetLife();
		}

	}
コード例 #23
0
 void lifeChangedCall(Life pLife)
 {
     int lLastLifeValue = lifeValue;
     lifeValue = pLife.getBloodValue();
     if (lifeValue > lLastLifeValue || lifeValue<=0 )
         return;
     if (life.harmType == Life.HarmType.explode)
     {
         myAnimation.CrossFade("fire2", 0.2f);
         if (Ai)
             Ai.lockMove(fire2AnimationState.length);
     }
     else if (!fire2AnimationState.enabled )
     {
         myAnimation.CrossFade("fire1", 0.1f);
         if (Ai)
             Ai.lockMove(fire1AnimationState.length);
     }
 }
コード例 #24
0
ファイル: MedicAI.cs プロジェクト: Seraphli/TheInsectersWar
    protected override void actionCommandUpdate()
    {
        Transform lAim = getNowAimTransform();
        if (enable && lAim)
        {
            bool lPreNeedRunAway = needRunAway;
            needRunAway = false;
            actionCommand.clear();
            //bool lMoveToAim = false;
            if (isFaceEnemy(treatedLayerValue))
            {
                //print("isFaceEnemy(treatedLayerValue");
                if (!lPreNeedRunAway)
                {
                    pathUpdate();
                }
                needRunAway = true;
                actionCommand = moveToAim(aimPosition, lAim);
            }
            else if (needTreat(treatedLayerValue))
            {
                //print("needTreat(treatedLayerValue)");
                actionCommand.Fire = true;
            }
            else
            {
                //探测需救助者
                var lTreat = treatDetect(treatedLayerValue);
                if (lTreat)
                {
                    treatAimLife = lTreat.GetComponent<Life>();
                    //actionCommand = moveToAim(aimPosition, lTreat);
                    actionCommand = moveToAim(lTreat.position, lTreat);
                }
                else
                    actionCommand = moveToAim(aimPosition, lAim);
            }

            actionCommandControl.setCommand(getCommand());
        }
    }
コード例 #25
0
ファイル: Enemy.cs プロジェクト: tareaPOO/Proyecto
        public virtual void ColisionCactus(Rectangle rect)
        {
            // Lifes = Life.Life3;
            //delay++;
            //if (delay >= 2)
            //{

                for (int i = 0; i < Cactu.Count; i++)
                {
                    delay++;
                    bool n = ((BasicSprite)Cactu[i]).Colision(rect);

                    if (delay >= 1800)
                    {
                    if (((BasicSprite)Cactu[i]).Colision(rect) && carga == 3)
                    {

                        Lifes = Life.Life2;
                        carga = 2;
                        delay = 0;
                    }
                    else if (((BasicSprite)Cactu[i]).Colision(rect) && carga == 2)
                    {

                        Lifes = Life.Life1;
                        carga = 1;
                        delay = 0;
                    }
                    else if (((BasicSprite)Cactu[i]).Colision(rect) && carga <= 1)
                    {
                        Lifes = Life.Life0;
                        carga = 0;
                        delay = 0;
                    }

                    }
                }

               // }
        }
コード例 #26
0
    //class NetData
    //{
    //    public NetData(int p1, int p2, double pTimestamp)
    //    {
    //        part1 = p1;
    //        part2 = p2;
    //        timestamp = pTimestamp;
    //    }
    //    public int part1;
    //    public int part2;
    //    public double timestamp;
    //}
    //System.Collections.Generic.Queue<NetData> netDataQueue
    //    = new System.Collections.Generic.Queue<NetData>();
    void Awake()
    {
        if (!soldier)
            soldier = gameObject.GetComponentInChildren<Soldier>();
        //if(!soldier)
        //	soldier=gameObject.GetComponentInChildren<Soldier>().getCharacter();
        //character = gameObject.GetComponentInChildren<Soldier>().getCharacter();
        soldierModelSmoothMove = GetComponent<SoldierModelSmoothMove>();
        character = soldier.getCharacter();
        actionCommandControl = gameObject.GetComponentInChildren<ActionCommandControl>();
        if (!life)
            life = gameObject.GetComponentInChildren<Life>();

        if (Network.isClient)
        {
            Destroy(soldier.GetComponentInChildren<SoldierAI>());
            //disappearTimer = gameObject.AddComponent<zzTimer>();
            //disappearTimer.setInterval(disappearTime);
            //disappearTimer.addImpFunction(disappear);
            //life.addDieCallback((x) => disappearTimer.enabled = false);
            if (!networkDisappear)
            {
                networkDisappear = gameObject.AddComponent<NetworkDisappear>();
                networkDisappear.life = life;
                networkDisappear.disenableWhenDisappear = new MonoBehaviour[] { soldier };
                networkDisappear.addDisappearEventReceiver(showDisappear);
            }
        }
        //if(disenableWhenDisappear ==null||disenableWhenDisappear.Length==0)
        //{
        //    disenableWhenDisappear
        //}
        //if( !zzCreatorUtility.isMine(gameObject.networkView ) )
        //{
        //	Destroy(soldier.GetComponentInChildren<SoldierAI>());
        //}
        //if(!soldier)
        //	Debug.LogError(gameObject.name);
    }
コード例 #27
0
ファイル: Metabolize.cs プロジェクト: SardineFish/LifeGameX
 public Autotomy(Life life, double energyCost) : base(TypeID, life, energyCost)
 {
     this.Name        = "Autotomy";
     this.Description = "Damage itself to gain Energy.";
 }
コード例 #28
0
 double GetDistLife(Life l1)
 {
     return(GetDist(l1.x, x, l1.y, y));
 }
コード例 #29
0
ファイル: EnemyMove.cs プロジェクト: S-R-N/Shooting-Stream
    void Start () {
        audioSource = gameObject.GetComponent<AudioSource>();
        score = GameObject.Find ("Score").GetComponent<ScoreText>();
		life = GameObject.Find ("Lifeber").GetComponent<Life> ();
	}
コード例 #30
0
ファイル: Special.cs プロジェクト: mauriciojuba/ProtoTCC
 void ApplyDamageLifeOverTime(/*substituir pelo script de life novo*/ Life Col)
 {
     Col.LifeQuant -= Time.deltaTime * Damage;
 }
コード例 #31
0
 /// <summary>
 /// 初始化属性数据
 /// </summary>
 public virtual void Init(int SceneID, LifeMCore Core, Life Parent)
 {
     m_Parent  = Parent;
     m_SceneID = SceneID;
 }
コード例 #32
0
ファイル: GridActionSkill.cs プロジェクト: 741645596/batgame
    public void StartWithTarget(Life Parent)
    {
        m_StartTime = Time.time;
        Vector3 scale = new Vector3(1.25f, 1.25f, 1.25f);

        base.StartWithTarget(Parent, null);

        GameObject posgo = m_Skin.ProPerty.HelpPoint.GetVauleByKey(HelpPointName.EffectPos);

        if (posgo != null)
        {
            //m_effectgo = SkillEffects._instance.LoadEffect("effect/prefab/", "1000011",posgo.transform.position,1.5f);
            GameObjectActionExcute       gae      = EffectM.LoadEffect(EffectM.sPath, "1000011", posgo.transform.position, BattleEnvironmentM.GetLifeMBornNode(true));
            GameObjectActionDelayDestory ndEffect = new GameObjectActionDelayDestory(1.5f);
            gae.AddAction(ndEffect);
            m_effectgo = gae.gameObject;
        }
        Role.RefreshSkin();
        //PlayAction(AnimatorState.Skill01,m_Start);

        (m_LifePrent as Role).SavePosZ();
        if (m_lifeMCore != null)
        {
            if (m_lifeMCore.m_IsPlayer)
            {
                //Debug.Log(" 己方释放大招!!!");
                List <Life> listRAW = new List <Life>();
                m_LifePrent.SetDark(false);
                //CM.SearchLifeMListInBoat(ref listRAW, LifeMType.ALL);
                CM.SearchLifeMList(ref listRAW, null, LifeMType.ALL, LifeMCamp.ALL, MapSearchStlye.AllWorld, null, 0);
                List <Role> rs      = new List <Role>();
                bool        ispause = false;
                foreach (Life item in listRAW)
                {
                    if (item != m_LifePrent)
                    {
                        if (item is Role)
                        {
                            Role r = item as Role;
                            if (r.CurrentAction != null && r.CurrentAction is GridActionCmdActiveSkill)
                            {
                                float starttime = (r.CurrentAction as GridActionCmdActiveSkill).m_StartTime;
                                if (starttime >= 0)
                                {
                                    if ((m_StartTime - starttime) > ConfigM.GetBigSkillDelatime())
                                    {
                                        ispause = true;
                                    }
                                    rs.Add(r);
                                }
                                else
                                {
                                    item.Pause();
                                    item.SetDark(true);
                                }
                            }
                            else
                            {
                                item.Pause();
                                item.SetDark(true);
                            }
                        }
                        else
                        {
                            item.Pause();
                            item.SetDark(true);
                        }
                    }
                }
                foreach (Role r in rs)
                {
                    if (ispause)
                    {
                        r.Pause();
                        r.SetDark(true);
                        (r.CurrentAction as GridActionCmdActiveSkill).m_StartTime = -1f;
                    }
                }
                MaterialM.DarkBattleEnv();
                m_Skin.Scale(scale);
                ParticleEffect.StaticPlay(false);
                Bullet.PauseAll();
            }
        }
        ActiiveStart();
        if (m_skillinfo.m_LifeTarget != null)
        {
            m_skillinfo.m_LifeTarget.SetDark(false);
        }
        else
        {
        }
    }
コード例 #33
0
 private void Awake()
 {
     _bulletLife = GetComponent <Life>();
     _movement   = GetComponent <Movement>();
     _movement.Jump(velocity);
 }
コード例 #34
0
 public override void StartWithTarget(Life Parent, StartAttackFun StartAttack)
 {
     base.StartWithTarget(Parent, StartAttack);
 }
コード例 #35
0
    public override void ActiiveStart()
    {
        Life w = m_LifePrent.m_Skill.m_SkillTarget;

        if (w is Role)
        {
            //Transform EffectPos = (w as Role).m_Skin.ProPerty.m_EffectPos;
            GameObject posgo = (w as Role).m_Skin.ProPerty.HelpPoint.GetVauleByKey(HelpPointName.EffectPos);
            if (posgo != null)
            {
                Vector3 pos = posgo.transform.position;
                pos.z = -1.5f;
                //SkillEffects._instance.LoadEffect("effect/prefab/", "1002051",pos,1f);
                GameObjectActionExcute       gae1      = EffectM.LoadEffect(EffectM.sPath, "1002051", pos, BattleEnvironmentM.GetLifeMBornNode(true));
                GameObjectActionDelayDestory ndEffect1 = new GameObjectActionDelayDestory(1f);
                gae1.AddAction(ndEffect1);
            }
        }
        SoundPlay.Play("skill_voice_yidao", false, false);
        SoundPlay.Play("skill_yidao_sstx", false, false);

        Life emeny = CM.GetAllLifeM(m_AttackSceneID, LifeMType.ALL);

        GameObjectActionExcute       gae      = EffectM.LoadEffect(EffectM.sPath, "1051041", BattleEnvironmentM.Local2WorldPos(m_TargetPos), BattleEnvironmentM.GetLifeMBornNode(true));
        GameObjectActionDelayDestory ndEffect = new GameObjectActionDelayDestory(m_action3);

        gae.AddAction(ndEffect);
        GameObject go = gae.gameObject;

        go.transform.parent        = m_Skin.tRoot;
        go.transform.localPosition = Vector3.zero;
        //m_LifePrent.InBoat  =false;
        MapGrid gfrom = m_LifePrent.GetMapGrid();

        m_TelePortGrid = gfrom;
        MapGrid gstart = gfrom;
        //m_Dir = WalkDir.WALKRIGHT;
        MapGrid gto       = emeny.GetTargetMapGrid();
        int     startunit = MapSize.GetGridStart(gto.GridPos.Layer);
        int     endtunit  = startunit + MapSize.GetLayerSize(gto.GridPos.Layer) - 1;
        //if (gto.GridPos.Layer > 0)
        MapGrid start = MapGrid.GetMG(gto.GridPos.Layer, startunit);
        MapGrid end   = MapGrid.GetMG(gto.GridPos.Layer, endtunit);
        MapGrid gl    = gto.GetNextAttackStation(DIR.LEFT, false);
        MapGrid gr    = gto.GetNextAttackStation(DIR.RIGHT, false);

        if (gl == null && gr == null)
        {
            Debug.LogError("xxxxxxxxxxxxxxxxXXXXXXXXXXXXXX " + gto.GridPos);
        }

        if (emeny is Role)
        {
            m_TargetPos = emeny.m_thisT.localPosition;
        }
        else
        {
            m_TargetPos = gto.pos;
        }
        if (gfrom.GridPos.Unit < startunit)
        {
            gstart = start;
        }
        else if (gfrom.GridPos.Unit > endtunit)
        {
            gstart = end;
        }
        if (gto.GridPos.Layer > 0)
        {
            int     upstartunit = MapSize.GetGridStart(gto.GridPos.Layer - 1);
            int     upendtunit  = upstartunit + MapSize.GetLayerSize(gto.GridPos.Layer - 1) - 1;
            MapGrid upstart     = MapGrid.GetMG(gto.GridPos.Layer - 1, upstartunit);
            MapGrid upend       = MapGrid.GetMG(gto.GridPos.Layer - 1, upendtunit);

            if (gfrom.GridPos.Unit < upstartunit)
            {
                gstart = upstart;
            }
            else if (gfrom.GridPos.Unit > upendtunit)
            {
                gstart = upend;
            }
        }
        m_gs = (m_LifePrent as Role).CurrentGS;
        if (m_gs == GridSpace.Space_UP)
        {
            m_LifePrent.m_thisT.localScale = new Vector3(m_LifePrent.m_thisT.localScale.x, -m_LifePrent.m_thisT.localScale.y, m_LifePrent.m_thisT.localScale.z);
        }
        if (gr != null && gstart.GridPos.Unit > gr.GridPos.Unit)
        {
            m_Dir             = WalkDir.WALKLEFT;
            m_PreTelePortGrid = gr;
            if (gl != null)
            {
                /*MapGrid temp = gl.GetNextAttackStation(DIR.LEFT,false);
                 * if ( temp!= null)
                 *      gl = temp;*/
                //w.Teleport(gl);
                m_TelePortGrid = gl;
                m_End          = gl.pos;
                //m_Dir = WalkDir.WALKLEFT;
            }
            else
            {
                m_TelePortGrid = gr;
                //w.Teleport(gr);
                m_End = gr.pos;
            }
            MapGrid oldgrid = null;
            if (gstart.GridPos.Unit - gr.GridPos.Unit <= 3)
            {
                oldgrid = MapGrid.GetMG(gr.GridPos.Layer, gstart.GridPos.Unit);
                if (m_gs == GridSpace.Space_DOWN)
                {
                    lpos.Add(gfrom.pos);
                    Vector3 upos = gr.Uppos;
                    upos.x += (oldgrid.Uppos.x - gr.Uppos.x) / 2;
                    lpos.Add(upos);
                    lpos.Add(gr.pos);
                }
                else
                {
                    lpos.Add(gfrom.Uppos);
                    lpos.Add(gr.pos);
                }
            }
            else
            {
                oldgrid = MapGrid.GetMG(gr.GridPos.Layer, gstart.GridPos.Unit);
                if (m_gs == GridSpace.Space_DOWN)
                {
                    lpos.Add(gfrom.pos);
                    Vector3 upos = gr.Uppos;
                    upos.x += (oldgrid.Uppos.x - gr.Uppos.x) * 3 / 4;
                    lpos.Add(upos);
                    lpos.Add(gr.pos + new Vector3((oldgrid.pos.x - gr.pos.x) / 2, 0, 0));
                    lpos.Add(gr.Uppos + new Vector3((oldgrid.Uppos.x - gr.Uppos.x) / 4, 0, 0));
                    lpos.Add(gr.pos);
                }
                else
                {
                    lpos.Add(gfrom.Uppos);

                    lpos.Add(gr.pos);
                }
            }
        }
        else if (gl != null && gstart.GridPos.Unit < gl.GridPos.Unit)
        {
            m_Dir             = WalkDir.WALKRIGHT;
            m_PreTelePortGrid = gl;
            if (gr != null)
            {
                /*MapGrid temp = gr.GetNextAttackStation(DIR.RIGHT,false);
                 * if ( temp!= null)
                 *      gr = temp;*/
                //w.Teleport(gr);
                m_TelePortGrid = gr;
                m_End          = gr.pos;
            }
            else
            {
                //w.Teleport(gl);
                m_TelePortGrid = gl;
                m_End          = gl.pos;
            }
            MapGrid oldgrid = null;
            if (gl.GridPos.Unit - gstart.GridPos.Unit <= 3)
            {
                oldgrid = MapGrid.GetMG(gl.GridPos.Layer, gstart.GridPos.Unit);
                if (m_gs == GridSpace.Space_DOWN)
                {
                    lpos.Add(gfrom.pos);
                    Vector3 upos = gl.Uppos;
                    upos.x += (oldgrid.Uppos.x - gl.Uppos.x) / 2;
                    lpos.Add(upos);
                    lpos.Add(gl.pos);
                }
                else
                {
                    lpos.Add(gfrom.Uppos);
                    lpos.Add(gl.pos);
                }
            }
            else
            {
                oldgrid = MapGrid.GetMG(gl.GridPos.Layer, gstart.GridPos.Unit);
                if (m_gs == GridSpace.Space_DOWN)
                {
                    lpos.Add(gfrom.pos);
                    Vector3 upos = oldgrid.Uppos;
                    upos.x += (gl.Uppos.x - oldgrid.Uppos.x) / 4;
                    lpos.Add(upos);
                    lpos.Add(oldgrid.pos + new Vector3((gl.pos.x - oldgrid.pos.x) / 2, 0, 0));
                    lpos.Add(oldgrid.Uppos + new Vector3((gl.Uppos.x - oldgrid.pos.x) * 3 / 4, 0, 0));
                    lpos.Add(gl.pos);
                }
                else
                {
                    lpos.Add(gfrom.Uppos);

                    lpos.Add(gl.pos);
                }
            }
        }
        else
        {
            if (gl != null && gfrom.GridPos.Unit < gto.GridPos.Unit)
            {
                m_Dir   = WalkDir.WALKRIGHT;
                m_Start = gl.pos;
                m_End   = gl.pos;

                m_PreTelePortGrid = gl;
                if (gr != null)
                {
                    lpos.Add(gfrom.pos);
                    Vector3 upos = gl.Uppos;
                    upos.x += (gr.Uppos.x - gl.Uppos.x) / 2;
                    lpos.Add(upos);
                    lpos.Add(gr.pos);
                    lpos.Add(upos);
                    lpos.Add(gl.pos);
                    //w.Teleport(gr);

                    m_TelePortGrid = gr;
                    m_End          = gr.pos;
                }
                else
                {
                    m_TelePortGrid = gl;
                    lpos.Add(gfrom.pos);
                    Vector3 upos = gl.Uppos;
                    lpos.Add(upos);
                    lpos.Add(gl.pos);
                    lpos.Add(upos);
                    lpos.Add(gl.pos);
                }
            }
            else if (gr != null && gfrom.GridPos.Unit > gto.GridPos.Unit)
            {
                m_PreTelePortGrid = gr;
                m_Dir             = WalkDir.WALKLEFT;
                m_Start           = gr.pos;
                m_End             = gr.pos;
                if (gl != null)
                {
                    lpos.Add(gfrom.pos);
                    Vector3 upos = gl.Uppos;
                    upos.x += (gr.Uppos.x - gl.Uppos.x) / 2;
                    lpos.Add(upos);
                    lpos.Add(gl.pos);
                    lpos.Add(upos);
                    lpos.Add(gr.pos);
                    //w.Teleport(gl);
                    m_TelePortGrid = gl;
                    m_End          = gl.pos;
                }
                else
                {
                    m_TelePortGrid = gr;
                    lpos.Add(gfrom.pos);
                    Vector3 upos = gr.Uppos;
                    lpos.Add(upos);
                    lpos.Add(gr.pos);
                    lpos.Add(upos);
                    lpos.Add(gr.pos);
                }
            }
            else
            {
                m_PreTelePortGrid = gto;
                m_Start           = gto.pos;
                m_End             = gto.pos;
                //Debug.Log("左右都没有攻击位" + gl.GridPos + "," + gr.GridPos + "," +gfrom.GridPos + "," + gto.GridPos.Unit);
            }
        }
        //PlayAction(AnimatorState.Skill01,m_Start,true);
#if UNITY_EDITOR_LOG
        string str = "lujin:";
        for (int i = 0; i < lpos.Count; i++)
        {
            str += lpos[i] + ", ";
        }
        //Debug.Log(str + ", mend " +m_End);
#endif
        if (lpos.Count > 0)
        {
            m_Start        = lpos[lpos.Count - 1];
            m_oncejumptime = m_JumpTime / (lpos.Count - 1);
            m_AniSpeed     = 0.8f / m_oncejumptime;
            m_gs           = (m_LifePrent as Role).CurrentGS;
            m_JumpCount    = 0;
        }

#if UNITY_EDITOR_LOG
        FileLog.write(m_LifePrent.SceneID, "能量燃烧 " + m_Start + "," + m_End + "," + m_TelePortGrid.GridPos + "," + m_Dir + "," + gfrom.GridPos + "," + gto.GridPos);
#endif
    }
コード例 #36
0
ファイル: Metabolize.cs プロジェクト: SardineFish/LifeGameX
 public EnergyToResource(Life life, double energyCost) : base(TypeID, life, energyCost)
 {
     this.Name        = "EnergyToSubstance";
     this.Description = "Transfer energy into substance.";
 }
コード例 #37
0
    public override void StartWithTarget(Life Parent, StartAttackFun StartAttack)
    {
        base.StartWithTarget(Parent, StartAttack);

        /*	Life emeny =  CM.GetAllLifeM(m_AttackSceneID,LifeMType.ALL);
         *
         *      GameObjectActionExcute gae = EffectM.LoadEffect(EffectM.sPath, "1051041", BattleEnvironmentM.Local2WorldPos(m_TargetPos), BattleEnvironmentM.GetLifeMBornNode(true));
         *      GameObjectActionDelayDestory ndEffect = new GameObjectActionDelayDestory(m_action3);
         *      gae.AddAction(ndEffect);
         *  GameObject go = gae.gameObject;
         *      go.transform.parent = m_Skin.tRoot;
         *      go.transform.localPosition = Vector3.zero;
         *      MapGrid gfrom = m_LifePrent.GetMapGrid();
         *      m_TelePortGrid = gfrom;
         *      MapGrid gstart = gfrom;
         *      //m_Dir = WalkDir.WALKRIGHT;
         *      MapGrid gto = emeny.GetTargetMapGrid();
         *      int startunit = MapSize.GetGridStart(gto.GridPos.Layer);
         *      int endtunit = startunit + MapSize.GetLayerSize(gto.GridPos.Layer) - 1;
         *      //if (gto.GridPos.Layer > 0)
         *      MapGrid start = MapGrid.GetMG(gto.GridPos.Layer,startunit);
         *      MapGrid end = MapGrid.GetMG(gto.GridPos.Layer,endtunit);
         *      MapGrid gl = gto.GetNextAttackStation(DIR.LEFT,false);
         *      MapGrid gr = gto.GetNextAttackStation(DIR.RIGHT,false);
         *      if (emeny is Role)
         *              m_TargetPos = emeny.transform.localPosition;
         *      else
         *              m_TargetPos = gto.pos;
         *      m_Start = m_Skin.tRoot.localPosition;
         *      m_End = m_Start;
         *      if (gfrom.GridPos.Unit > gto.GridPos.Unit)
         *      {
         *              m_Dir = WalkDir.WALKLEFT;
         *              m_Start = gfrom.pos;
         *              if (gr != null)
         *                      m_Start = gr.pos;
         *              if (gl != null)
         *              {
         *                      m_TelePortGrid = gl;
         *                      m_End = gl.pos;
         *              }
         *              else if (gr != null){
         *                      m_TelePortGrid = gr;
         *                      m_End = m_TelePortGrid.pos;
         *              }
         *              else
         *                      Debug.Log(gto.GridPos + "左右都没有攻击位");
         *      }
         *      else
         *      {
         *              m_Dir = WalkDir.WALKRIGHT;
         *              m_Start = gfrom.pos;
         *              if (gl != null)
         *                      m_Start = gl.pos;
         *              if (gr !=null)
         *              {
         *                      m_TelePortGrid = gr;
         *                      m_End = m_TelePortGrid.pos;
         *              }
         *              else if (gl != null)
         *              {
         *                      m_TelePortGrid = gl;
         *                      m_End = m_TelePortGrid.pos;
         *              }
         *              else
         *                      Debug.Log(gto.GridPos + "左右都没有攻击位");
         *      }
         *      m_LifePrent.InBoat =false;
         *      GameObject posgo = m_Skin.ProPerty.HelpPoint.GetVauleByKey(HelpPointName.EffectPos);
         *      if (posgo != null)
         *      {
         *              //GameObject gobj = SkillEffects._instance.LoadEffect("effect/prefab/", "1051161",posgo.transform.position,1.0f);
         *              GameObjectActionExcute gae1 = EffectM.LoadEffect(EffectM.sPath, "1051161", posgo.transform.position, BattleEnvironmentM.GetLifeMBornNode(true));
         *              GameObjectActionDelayDestory ndEffect1 = new GameObjectActionDelayDestory(1f);
         *              gae1.AddAction(ndEffect1);
         *      GameObject gobj = gae1.gameObject;
         *      }
         *      m_Skin.ProPerty.SetVisable(false);*/
#if UNITY_EDITOR
        //Debug.Log("闪烁突袭 " + m_Start + "," + m_End + "," + m_TelePortGrid.GridPos + "," + m_Dir);
        //FileLog.write(m_LifePrent.SceneID, "闪烁突袭 "+ m_Start + "," + m_End + "," + m_TelePortGrid.GridPos + "," + m_Dir + "," + gfrom.GridPos + "," + gto.GridPos);
#endif
    }
コード例 #38
0
 private void Start()
 {
     _life = GetComponentInParent <Life>();
 }
コード例 #39
0
 public Cell(Life alive)
 {
     Alive = alive;
 }
コード例 #40
0
ファイル: Metabolize.cs プロジェクト: SardineFish/LifeGameX
 public override Behaviour Clone(Life life)
 {
     return(new ResourceToEnergy(life, this.EnergyCost.Value));
 }
コード例 #41
0
ファイル: Spike.cs プロジェクト: Studio-miyaD/GamePG
 void Start()
 {
     lifeScript = GameObject.FindGameObjectWithTag("HP").GetComponent <Life> ();
 }
コード例 #42
0
ファイル: Mutate.cs プロジェクト: SardineFish/LifeGameX
 public Mutate(Life life, double energyCost) : base(TypeID, life, energyCost)
 {
     this.Name        = "Mutate";
     this.Description = "Change the species, and rebuild some reactions.";
     this.Weight      = 20;
 }
コード例 #43
0
ファイル: GridActionSkill.cs プロジェクト: 741645596/batgame
    public virtual void DoAttack(int count)
    {
        if (count == 1)
        {
            SoldierSkill skill = m_skillinfo as SoldierSkill;
            if (skill.m_Screen == 1)
            {
                MainCameraM.s_Instance.transform.DOShakePosition(skill.m_ScreenTime);
            }
        }
        Life    target = m_skillinfo.m_LifeTarget;    //m_ConditionSkillTarget[PropSkillInfo.m_type];
        MapGrid pos    = m_skillinfo.m_TargetPos;     //m_ConditionSkillTargetPos[PropSkillInfo.m_type];

        if (m_skillinfo.m_target != 2 && target != null)
        {
            pos = target.GetMapGrid();
        }
        //if (PropSkillInfo.m_type == 1009 || PropSkillInfo.m_type == 1028)
        //	NGUIUtil.DebugLog( "doskill " + PropSkillInfo.m_type  + "," +  m_ConditionSkillTarget[PropSkillInfo.m_type] + "," + PropSkillInfo.m_name,"red");
        //播放攻击动画
        //受击掉血
        m_LifePrent.m_Attr.Attacked = true;

        if (m_skillinfo.m_skilleffectinfo != null && m_skillinfo.m_type != 1005)        //RoleModelsM.GetSkillResourcesData(PropSkillInfo.m_type,"HasBullet") == 1)
        {
            GameObject posgo = m_LifePrent.GetSkin().ProPerty.HelpPoint.GetVauleByKey(HelpPointName.FirePos);

            /*if (m_skillinfo.m_type == 1041)
             *      posgo = m_LifePrent.GetSkin().ProPerty.HelpPoint.GetVauleByKey(HelpPointName.LeftHandPos);
             * else if (m_skillinfo.m_type == 1044)
             *      posgo = m_LifePrent.GetSkin().ProPerty.HelpPoint.GetVauleByKey(HelpPointName.bagPos);*/
            Transform fireplace = posgo.transform;
            if (fireplace != null)
            {
                string bulletname = m_skillinfo.m_skilleffectinfo.m_targeteffect;

                if (BattleEnvironmentM.GetLifeMBornNode(true) == null)
                {
                    return;
                }
                GameObject go = GameObjectLoader.LoadPath("effect/prefab/", bulletname, fireplace.position, BattleEnvironmentM.GetLifeMBornNode(true));
                if (m_LifePrent.WalkDir == WalkDir.WALKRIGHT)
                {
                    go.transform.Rotate(0, 180, 0);
                }
                //go.transform.localScale = new Vector3(-go.transform.localScale.x,go.transform.localScale.y,go.transform.localScale.z);
                Bullet bullet = go.AddComponent <Bullet>();
                if (bullet != null)
                {
                    Bullet.BulletType t    = Bullet.BulletType.Bullet;
                    Vector3           vpos = pos.pos;
                    if (m_skillinfo.m_skilleffectinfo.m_postion == 0)
                    {
                        vpos.y = go.transform.localPosition.y;
                    }
                    else
                    {
                        vpos.y += 0.2f;
                    }
                    bullet.SetInfo(vpos, m_DoAttack, 5f, m_LifePrent.WalkDir, t, (m_skillinfo as SoldierSkill), true);
                    //vpos,m_DoAttack,10f,m_LifePrent.WalkDir,t,m_skillinfo as SoldierSkill);
                }
            }
        }
        else
        {
            m_DoAttack(m_skillinfo as SoldierSkill, count);
        }
        //m_DoAttack(count);
    }
コード例 #44
0
ファイル: Mutate.cs プロジェクト: SardineFish/LifeGameX
 public override Behaviour Clone(Life life)
 {
     return(new Mutate(life, this.EnergyCost.Value));
 }
コード例 #45
0
ファイル: ClawnLife.cs プロジェクト: gameslucas/UTFPRJam
 private void Update()
 {
     _textMesh.text = Life.ToString();
 }
コード例 #46
0
    /// <summary>
    /// 创建FireActionCmd
    /// </summary>
    public static BornActionCmd Create(Life Parent, Vector3 JumpTarget, WalkDir JumpDir, DoneCallBack dcb, AnimatorState state, bool bFallSmooth)
    {
        string strBornEffect = "";
        int    ModeType      = Parent.m_Attr.ModelType;
        float  fduration     = 0.0f;

        if (ModeType == 100002 || ModeType == 200001)
        {
            fduration = 1.167f;
        }
        else if (ModeType == 100001 || ModeType == 200000)
        {
            fduration = 1.5f;
        }
        else if (ModeType == 100003 || ModeType == 100004 || ModeType == 101001)
        {
            fduration = 1f;
        }
        else if (ModeType == 101002)
        {
            if (bFallSmooth)
            {
                fduration = 1.067f;
            }
            else
            {
                fduration = 4.167f;
            }
        }
        else if (ModeType == 102001)
        {
            fduration = 2.0f;
        }
        else if (ModeType == 102002)
        {
            fduration = 1.333f;
        }
        else if (ModeType == 102005)
        {
            fduration = 1.0f;
        }
        else if (ModeType == 101003)
        {
            fduration     = 1.06f;
            strBornEffect = "1054011";
        }
        else if (ModeType == 200002)
        {
            fduration = 1.0f;
        }
        else if (ModeType == 200003)
        {
            fduration = 1.5f;
        }
        else if (ModeType == 200004)
        {
            fduration = 1.167f;
        }
        else if (ModeType == 200005)
        {
            fduration = 1.167f;
        }
        else if (ModeType == 200006)
        {
            fduration = 1.333f;
        }
        else if (ModeType == 200007)
        {
            fduration = 1.167f;
        }
        else if (ModeType == 200008)
        {
            fduration = 1.0f;
        }
        else if (ModeType == 102003 || ModeType == 200009)
        {
            fduration = 1.333f;
        }
        else if (ModeType == 3000)
        {
            fduration = 1.5f;
        }
        else if (ModeType == 102004)
        {
            fduration = 1.167f;
        }
        else if (ModeType == 101004)
        {
            fduration = 1f;
            (Parent.GetSkin() as RoleSkin).SetVisable(true);
            (Parent.GetSkin() as RoleSkin).EnableTrail(false);
        }
        else if (ModeType == 103003)
        {
            fduration = 1f;
            (Parent.GetSkin() as RoleSkin).SetVisable(true);
            (Parent.GetSkin() as RoleSkin).EnableTrail(false);
        }
        else if (ModeType == 103002)
        {
            fduration = 1.167f;
        }
        else if (ModeType == 103001)
        {
            fduration = 1.167f;
            (Parent.GetSkin() as RoleSkin).SetVisable(true);
            GameObject posgo = Parent.GetSkin().ProPerty.HelpPoint.GetVauleByKey(HelpPointName.EffectBottomPos);
            if (posgo != null)
            {
                Vector3 pos = posgo.transform.position;
                GameObjectActionExcute gae      = EffectM.LoadEffect(EffectM.sPath, "1201011", pos, posgo.transform);
                GameObjectActionRepeat ndEffect = new GameObjectActionRepeat();
                gae.AddAction(ndEffect);
            }
        }

        else
        {
            Debug.LogError("BornActionCmdFactory 请创建对应的炮战Action");
            return(null);
        }
                #if UNITY_EDITOR_LOG
        FileLog.write(Parent.SceneID, "Born  " + ModeType + "," + fduration);
                #endif
        return(new BornActionCmd(Parent, JumpTarget, JumpDir, dcb, fduration, state, bFallSmooth, strBornEffect));
    }
コード例 #47
0
ファイル: Special.cs プロジェクト: mauriciojuba/ProtoTCC
 void ApplyDamageLife(/*substituir pelo script de life novo*/ Life Col)
 {
     Col.LifeQuant -= Damage;
 }
コード例 #48
0
ファイル: BloodBar.cs プロジェクト: Seraphli/TheInsectersWar
 public void setLife(Life pLife)
 {
     life = pLife;
     life.addBloodValueChangeCallback(UpdateBar);
 }
コード例 #49
0
 public void  SetLifeData(int SceneID, Life Parent)
 {
     m_SceneID = SceneID;
     m_Parent  = Parent;
 }
コード例 #50
0
        static void Main(string[] args)
        {
            // create a neural network, without using a factory
            Random rnd = new Random((int)(DateTime.Now.Ticks % int.MaxValue));

            for (int i = 0; i < 23; i++)
            {
                Life life = new Life(world, rnd.NextDouble(), rnd.NextDouble());
                world.Add(life);
            }

            int width  = 640;
            int height = 480;

            frame = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            string name           = String.Format("{0}.avi", DateTime.Now.ToString());
            String outputFilePath = name.Replace(":", "_");

            AVI.Writer.NewWriter(outputFilePath, width, height);
            //AnimatedGifEncoder e = new AnimatedGifEncoder();
            //e.Start(outputFilePath);
            //e.SetDelay(5);
            //e.SetRepeat(0);
            //add a new video stream and one frame to the new file

            //var writer = new VideoWriter(Guid.NewGuid().ToString() + ".avi", new DotImaging.Primitives2D.Size(640, 480), 30f, true);
            //writer.Open();

            int num = 0;

            g = Graphics.FromImage(frame);
            do
            {
                num++;
                try
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    //foreach (var life in world)
                    //{
                    //    try
                    //    {
                    //        life.DoLive();
                    //    }
                    //    catch (Exception)
                    //    {
                    //    }
                    //}
                    Parallel.ForEach(world.Cast <Life>(),
                                     life =>
                    {
                        life.DoLive();
                    });
                    sw.Stop();
                    //Console.SetCursorPosition(0, 4);
                    //Console.Write("Tick: " + sw.ElapsedMilliseconds);
                    sw.Reset(); sw.Start();
                    Draw();

                    //frame.Save(name);
                    //if (num%2==0)
                    //{
                    //    e.AddFrame(frame);
                    //}
                    AVI.Writer.AddFrame(frame);
                    sw.Stop();
                    //Console.SetCursorPosition(0, 5);
                    //Console.Write("Draw: " + sw.ElapsedMilliseconds);
                }
                catch (Exception esx)
                {
                    //Console.SetCursorPosition(0, 6);
                    //Console.Write(esx.Message + esx.Source + esx.StackTrace);
                }
                //Console.SetCursorPosition(0, 7);
                //Console.Write(num);
                if (num >= 100)
                {
                    num = 0;
                    Console.Clear();
                    //AVI.Writer.Close();
                    ////e.Finish();
                    //break;
                }
            } while (true);

            EncogFramework.Instance.Shutdown();
        }
コード例 #51
0
        static void Draw()
        {
            //Console.Clear();
            //g.Clear(Color.Black);
            g.FillRectangle(new SolidBrush(Color.FromArgb(25, Color.Black)), new Rectangle(0, 0, frame.Width, frame.Height));
            foreach (var life in world)
            {
                int xx = (int)Math.Ceiling(life.x * 50.0);
                int yy = (int)Math.Ceiling(life.y * 40.0);

                Console.SetCursorPosition(xx, yy);
                if (life.borncount > 0)
                {
                    Console.ForegroundColor = ConsoleColor.Magenta;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.White;
                }
                Console.Write("#");
                Life nearlife = null; double mind = 9999;
                xx = (int)Math.Ceiling(life.x * frame.Width);
                yy = (int)Math.Ceiling(life.y * frame.Height);

                foreach (Life lifeform in world)
                {
                    if (life.id != lifeform.id)
                    {
                        var d = GetDist(lifeform.x, life.x, lifeform.y, life.y);
                        if (d < mind)
                        {
                            mind     = d;
                            nearlife = lifeform;
                            if (d < 0.02)
                            {
                                g.FillEllipse(new SolidBrush(Color.FromArgb(255, 255, 255, 255)), new Rectangle(xx - 15, yy - 15, 30, 30));
                            }
                        }
                    }
                }
                byte dk = (byte)(life.borncount * 45);
                byte dg = (byte)(life.nearcount * 45);
                if (nearlife != null)
                {
                    var  sL = GetDist(life.x - 0.05, nearlife.x, life.y, nearlife.y);
                    var  sR = GetDist(life.x + 0.05, nearlife.x, life.y, nearlife.y);
                    var  sB = GetDist(life.x, nearlife.x, life.y - 0.05, nearlife.y);
                    var  sT = GetDist(life.x, nearlife.x, life.y + 0.05, nearlife.y);
                    byte dL = (byte)Math.Floor(Math.Abs(255 - sL * 400.0));
                    byte dR = (byte)Math.Floor(Math.Abs(255 - sR * 400.0));
                    byte dB = (byte)Math.Floor(Math.Abs(255 - sB * 400.0));
                    byte dT = (byte)Math.Floor(Math.Abs(255 - sT * 400.0));

                    g.FillEllipse(new SolidBrush(Color.FromArgb(255, dL, dk, dg)), new Rectangle(xx - 15, yy - 5, 5, 5));
                    g.FillEllipse(new SolidBrush(Color.FromArgb(255, dR, dk, dg)), new Rectangle(xx + 5, yy - 5, 5, 5));
                    g.FillEllipse(new SolidBrush(Color.FromArgb(255, dB, dk, dg)), new Rectangle(xx - 5, yy + 5, 5, 5));
                    g.FillEllipse(new SolidBrush(Color.FromArgb(255, dT, dk, dg)), new Rectangle(xx - 5, yy - 15, 5, 5));
                }
                g.FillEllipse(new SolidBrush(Color.FromArgb(255, dk, dg)), new Rectangle(xx - 10, yy - 10, 15, 15));
            }
        }
コード例 #52
0
            void RefreshSense()
            {
                ret1 : double mind = 99999;
                sL = 0;
                sR = 0;
                sB = 0;
                sT = 0;
                try
                {
                    foreach (Life life in World)
                    {
                        if (life.id != this.id)
                        {
                            var d = GetDistLife(life);
                            if (d < mind)
                            {
                                mind     = d;
                                nearlife = life;
                                if (d < 0.008)
                                {
                                    if (rnd.NextDouble() > 0.7)//born new life form 70%
                                    {
                                        if (starttimeout > 30)
                                        {
                                            if (nearlife.starttimeout > 30)
                                            {
                                                borncount += 1;
                                                if (borncount > 5)
                                                {
                                                    borncount = 5;
                                                }
                                                nearlife.borncount += 1;
                                                if (nearlife.borncount > 5)
                                                {
                                                    nearlife.borncount = 5;
                                                }
                                                if (nearlife.nearcount < nearcount)
                                                {
                                                    World.Remove(nearlife);
                                                }
                                                else
                                                {
                                                    World.Remove(this);
                                                }
                                                //World.Remove(nearlife);
                                                //World.Remove(this);
                                                goto ret1;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (borntimeout > 10)
                                        {
                                            if (nearlife.borntimeout > 10)
                                            {
                                                borntimeout          = 0;
                                                nearlife.borntimeout = 0;
                                                if (nearlife.nearcount < nearcount)
                                                {
                                                    Life newlife = new Life(World, x + rnd.NextDouble() / 20 - rnd.NextDouble() / 20, y + rnd.NextDouble() / 20 - rnd.NextDouble() / 20, genotype, this);
                                                    world.Add(newlife);
                                                }
                                                else
                                                {
                                                    Life newlife = new Life(World, x + rnd.NextDouble() / 20 - rnd.NextDouble() / 20, y + rnd.NextDouble() / 20 - rnd.NextDouble() / 20, nearlife.genotype, nearlife);
                                                    world.Add(newlife);
                                                }
                                                borncount -= 1;
                                                if (borncount < 0)
                                                {
                                                    borncount = 0;
                                                }
                                                nearlife.borncount -= 1;
                                                if (nearlife.borncount < 0)
                                                {
                                                    nearlife.borncount = 0;
                                                }
                                            }
                                        }
                                    }
                                    nearcount += 1;
                                    if (nearcount > 5)
                                    {
                                        nearcount = 5;
                                    }
                                    nearlife.nearcount += 1;
                                    if (nearlife.nearcount > 5)
                                    {
                                        nearlife.nearcount = 5;
                                    }
                                    //x = (rnd.NextDouble()+x)/2;
                                    //y = (rnd.NextDouble()+y)/2;
                                    //life.x = (rnd.NextDouble() + 0.04 + life.x) / 2;
                                    //life.y = (rnd.NextDouble() + 0.04 + life.y) / 2;
                                }
                            }
                            if (nearlife != null)
                            {
                                if (nearlife.borncount < borncount)
                                {
                                    sL += Math.Pow(GetDist(x - 0.05, nearlife.x, y, nearlife.y), 2) / 10;
                                    sR += Math.Pow(GetDist(x + 0.05, nearlife.x, y, nearlife.y), 2) / 10;
                                    sB += Math.Pow(GetDist(x, nearlife.x, y - 0.05, nearlife.y), 2) / 10;
                                    sT += Math.Pow(GetDist(x, nearlife.x, y + 0.05, nearlife.y), 2) / 10;
                                }
                                else
                                {
                                    sL -= Math.Pow(GetDist(x - 0.05, nearlife.x, y, nearlife.y), 2) / 10;
                                    sR -= Math.Pow(GetDist(x + 0.05, nearlife.x, y, nearlife.y), 2) / 10;
                                    sB -= Math.Pow(GetDist(x, nearlife.x, y - 0.05, nearlife.y), 2) / 10;
                                    sT -= Math.Pow(GetDist(x, nearlife.x, y + 0.05, nearlife.y), 2) / 10;
                                }
                            }
                        }
                    }
                }
                catch (Exception ee)
                {
                    string s = ee.Message;

                    goto ret1;
                }
                if (nearlife != null)
                {
                    sL = GetDist(x - 0.05, nearlife.x, y, nearlife.y) + sL / 10;
                    sR = GetDist(x + 0.05, nearlife.x, y, nearlife.y) + sR / 10;
                    sB = GetDist(x, nearlife.x, y - 0.05, nearlife.y) + sB / 10;
                    sT = GetDist(x, nearlife.x, y + 0.05, nearlife.y) + sT / 10;
                }
            }
コード例 #53
0
ファイル: Enemy.cs プロジェクト: Ulises12/ProyectoFinal
        //Cargar aqui los valores de los sprites de vivoras
        //Cargar aqui los valores de los sprites de murcielagos
        public virtual void LoadLifes(ContentManager Content)
        {
            Life0 = new BasicSprite();
            Life0.LoadContent(Content, "Life", "LifeCero");

            Life1 = new BasicSprite();
            Life1.LoadContent(Content, "Life", "LifeUno");

            Life2 = new BasicSprite();
            Life2.LoadContent(Content, "Life", "LifeDos");

            Life3 = new BasicSprite();
            Life3.LoadContent(Content, "Life", "LifeTres");

            GameOver = new BasicSprite();
            GameOver.LoadContent(Content, "Menu", "gameover");

            GObob = new BasicSprite();
            GObob.LoadContent(Content, "Menu", "GObob");

            Lifes = Life.Life3;
        }
コード例 #54
0
 public GolemResurrect(LietoResurrectSignal resurrectSignal, CharacterMotor motor, Life life, EnemyAttackAI ai) : base(resurrectSignal, motor, life)
 {
     _attackAi = ai;
 }
コード例 #55
0
 internal void StopLife()
 {
     Life.Dispose();
     Life = null;
 }
コード例 #56
0
ファイル: Metabolize.cs プロジェクト: SardineFish/LifeGameX
 public Cure(Life life, double energyCost) : base(TypeID, life, energyCost)
 {
     this.Name        = "Cure";
     this.Description = "Increase Health which will cost energy.";
 }
コード例 #57
0
 public override void collision(Actor a)
 {
     Life.collisionDamage(this, a, this.damage);
 }
コード例 #58
0
        public void InitDefault()
        {
            ArraySize.SetValue(Vector3.One);
            ArrayModulo.SetValue(1);

            var colorAnim = new MyAnimatedPropertyVector4();

            colorAnim.AddKey(0, Vector4.One);
            colorAnim.AddKey(0.33f, Vector4.One);
            colorAnim.AddKey(0.66f, Vector4.One);
            colorAnim.AddKey(1, Vector4.One);
            Color.AddKey(0, colorAnim);

            var colorIntensityAnim = new MyAnimatedPropertyFloat();

            colorIntensityAnim.AddKey(0, 1.0f);
            colorIntensityAnim.AddKey(0.33f, 1.0f);
            colorIntensityAnim.AddKey(0.66f, 1.0f);
            colorIntensityAnim.AddKey(1, 1.0f);
            ColorIntensity.AddKey(0, colorIntensityAnim);

            Offset.SetValue(new Vector3(0, 0, 0));
            Direction.SetValue(new Vector3(0, 0, -1));

            var radiusAnim = new MyAnimatedPropertyFloat();

            radiusAnim.AddKey(0, 0.1f);
            radiusAnim.AddKey(0.33f, 0.1f);
            radiusAnim.AddKey(0.66f, 0.1f);
            radiusAnim.AddKey(1, 0.1f);
            Radius.AddKey(0, radiusAnim);

            var thicknessAnim = new MyAnimatedPropertyFloat();

            thicknessAnim.AddKey(0, 1.0f);
            thicknessAnim.AddKey(0.33f, 1.0f);
            thicknessAnim.AddKey(0.66f, 1.0f);
            thicknessAnim.AddKey(1, 1.0f);
            Thickness.AddKey(0, thicknessAnim);

            Life.SetValue(1);
            LifeVar.SetValue(0);

            StreakMultiplier.SetValue(4);
            AnimationFrameTime.SetValue(1);

            Enabled.SetValue(true);

            EmitterSize.AddKey(0, new Vector3(0.0f, 0.0f, 0.0f));
            EmitterSizeMin.AddKey(0, 0.0f);
            DirectionInnerCone.AddKey(0, 0.0f);
            DirectionConeVar.AddKey(0, 0.0f);

            Velocity.AddKey(0, 1.0f);
            VelocityVar.AddKey(0, 0.0f);

            ParticlesPerSecond.AddKey(0, 1000.0f);
            Material.SetValue(MyTransparentMaterials.GetMaterial("WhiteBlock"));

            SoftParticleDistanceScale.SetValue(1);
            Bounciness.SetValue(0.5f);
            ColorVar.SetValue(0);
            HueVar.SetValue(0);

            RotationEnabled.SetValue(true);
            MotionInheritance.SetValue(0);

            OITWeightFactor.SetValue(1f);

            TargetCoverage.SetValue(1f);
        }
コード例 #59
0
 //在死亡的回调中使用
 void deadAction(Life p)
 {
     objectToSet.enabled = enabledToSet;
 }
コード例 #60
0
            public Life(List <Life> world, double X, double Y, List <LayerConfig> newgen = null, Life parent = null)
            {
                x  = X;
                y  = Y;
                pL = pR = pB = pT = 0.0;
                sL = sR = sB = sT = 0.0;
                network.AddLayer(new BasicLayer(null, true, 4)); //создание простой многослойной нейронной сети

                if (newgen == null)
                {
                    int maxlayers = 3 + rnd.Next(15);
                    for (int i = 0; i < maxlayers; i++)
                    {
                        bool bias  = rnd.NextDouble() >= 0.5;
                        var  layer = new LayerConfig((byte)rnd.Next(0, 16), bias, rnd.Next(100) + 10);
                        genotype.Add(layer);
                    }
                }
                else
                {
                    genotype = Mutate(newgen);
                }

                AddLayers(genotype);
                if (parent != null)
                {
                    for (int i = 0; i < parent.Memory.Count; i++)
                    {
                        if (rnd.NextDouble() > 0.5)
                        {
                            Memory.Add(parent.Memory[i]);
                            MemorySense.Add(parent.MemorySense[i]);
                        }
                    }
                }
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax (), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationStep (), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationStep(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationStep(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, rnd.Next(100) + 10));
                network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 4));

                network.Structure.FinalizeStructure();
                network.Reset();
                World = world;
            }