当前位置: 首页>>代码示例>>C#>>正文


C# Individual.CheckPlayerState方法代码示例

本文整理汇总了C#中Individual.CheckPlayerState方法的典型用法代码示例。如果您正苦于以下问题:C# Individual.CheckPlayerState方法的具体用法?C# Individual.CheckPlayerState怎么用?C# Individual.CheckPlayerState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Individual的用法示例。


在下文中一共展示了Individual.CheckPlayerState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PerformMyDecision

  //this method signature means swap
  public void PerformMyDecision (Mask myMaskToSwap, Individual swapW)
  {
    if (myMaskList.Count > 0 && swapW.myMaskList.Count > 0 && myMaskToSwap.MyOwner.Index != swapW.Index) {
      //Debug.Log ("Performing a swap decision. " + Index);
      int myRand = Random.Range (0, myMaskList.Count);
      int theirRand = Random.Range (0, swapW.myMaskList.Count);

      Individual orig_parent = myMaskToSwap.MyOwner;
      if (swapW.Index == Index) {
        //Debug.Log ("I'm swapping WITH MYSELF!!");
      }

      if (GameManager.instance.TurnPosition == 0) {
        //Debug.Log ("Swap on turn position = " + GameManager.instance.TurnPosition);
        //mySwapMask = myMaskToSwap;
        myRand = myMaskList.IndexOf (myMaskToSwap);
      } 

      //first store both the masks to be swapped in temp variables
      Mask myPotentialMaskToSwap = myMaskList [myRand];
      Mask theirPotentialMaskToSwap = swapW.myMaskList [theirRand];

      myMaskList.Remove (myPotentialMaskToSwap);
      swapW.myMaskList.Remove (theirPotentialMaskToSwap); 


      myMaskList.Insert (myRand, theirPotentialMaskToSwap);
      swapW.myMaskList.Insert (theirRand, myPotentialMaskToSwap);

      //tell me everything in my list
      foreach(Mask msk in myMaskList){
        //Debug.Log (" my Mask List after INSERT"+ msk.MyMaskType);
        switch(msk.MyMaskType){
        case MaskType.Attack:
          msk.GetComponent<Image>().sprite = msk.myPossibleMaskImages[0];
          break;
        case MaskType.Defend:
          msk.GetComponent<Image>().sprite = msk.myPossibleMaskImages[1];
          break;
        case MaskType.Switch:
          msk.GetComponent<Image>().sprite = msk.myPossibleMaskImages[2];

          break;
        default:
          break;
        }
      }
      foreach(Mask msk in swapW.myMaskList){
        //Debug.Log (" their mask list after INSERT " + msk.MyMaskType);
        //tell me everything in their list
          switch(msk.MyMaskType){
          case MaskType.Attack:
            msk.GetComponent<Image>().sprite = msk.myPossibleMaskImages[0];
            break;
          case MaskType.Defend:
            msk.GetComponent<Image>().sprite = msk.myPossibleMaskImages[1];
            break;
          case MaskType.Switch:
            msk.GetComponent<Image>().sprite = msk.myPossibleMaskImages[2];
            break;
          default:
            break;
        }
      }
      //Set the new parent
      theirPotentialMaskToSwap.gameObject.transform.SetParent (orig_parent.transform, false);
      theirPotentialMaskToSwap.gameObject.GetComponent<RectTransform>().localPosition = new Vector3(0,0,0);
      theirPotentialMaskToSwap.MyOwner = orig_parent;

      //Debug.Log ("*******Their mask to swap OWNER= "+theirPotentialMaskToSwap.MyOwner.Index );
      myPotentialMaskToSwap.gameObject.transform.SetParent (swapW.transform, false);
      myPotentialMaskToSwap.gameObject.GetComponent<RectTransform>().localPosition = new Vector3(0,0,0);
      myPotentialMaskToSwap.MyOwner = swapW;
      //Debug.Log ("********MY mask to swap OWNER= "+myPotentialMaskToSwap.MyOwner.Index );

      if(myMaskList[myMaskList.Count-1] == null){
        myMaskList.RemoveAt(myMaskList.Count-1);
      }

      if(swapW.myMaskList[swapW.myMaskList.Count-1] == null){
        swapW.myMaskList.RemoveAt(swapW.myMaskList.Count-1);
      }

      foreach(Mask msk in myMaskList){
        if(msk == null){
          myMaskList.Remove(msk);
        }
      }

      foreach(Mask msk in swapW.myMaskList){
        if(msk == null){
          swapW.myMaskList.Remove(msk);
        }
      }

      CheckPlayerState ();
      swapW.CheckPlayerState ();
      DisplayOnlyTopMask ();
      swapW.DisplayOnlyTopMask ();
//.........这里部分代码省略.........
开发者ID:taylorjames9,项目名称:Masks,代码行数:101,代码来源:Individual.cs


注:本文中的Individual.CheckPlayerState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。